gatsby-plugin-schema-snapshot avoid WebP picture source from a Json data source
See original GitHub issueHi, I have a project with some Json as data source: I added the gatsby-plugin-schema-snapshot
plugin to speed up my build time and I saw that the images served by the gatsby-image
component stopped delivering the WebP picture source.
Here a demo of the issue: https://codesandbox.io/s/infallible-snow-i60fj
I changed the image
component to get the image childImage
field querying the Json source (in the data directory) instead of querying the file system directly.
The source with the WebP format is missing:
.
I don’t knpw if it’s correlated but during the build I have this warning message:
The type `File` does not explicitly define the field `childDataJson`. On types with the `@dontInfer` directive, or with the `infer` extension set to `false`, automatically adding fields for children types is deprecated. In Gatsby v3, only children fields explicitly set with the `childOf` extension
Thanks valse
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
For the file warning - you could add the following to
gatsby-node.js
:This should fix the warning. There is a bit more context on this in #19674
This is certainly a bug that I can reproduce.
As a workaround (for now), you can exclude
gatsby-transformer-sharp
from snapshot plugin:Which seems to make it work again.
I’m not sure where to attribute this bug to. With snapshot enabled (and not excluding types from sharp transformer), we get following types in schema:
Now, resolver for
fluid
field works fine ( https://github.com/gatsbyjs/gatsby/blob/08d63c5e4ed25e9315101dec4fdb98186c527927/packages/gatsby-transformer-sharp/src/customize-schema.js#L357-L375 ), but resolver forsrcWebp
(and probably rest of those resolvers on field ofImageSharpFluid
type, I just checked one) is not being hit ( https://github.com/gatsbyjs/gatsby/blob/08d63c5e4ed25e9315101dec4fdb98186c527927/packages/gatsby-transformer-sharp/src/customize-schema.js#L236-L252 ). So my gut tells me default resolver is used and because there is no actualsrcWebp
on object return byfluid
- this just make itnull
?My guess -
ImageSharp
type is defined withschema.buildObjectType
which seems to play nicely with schema customization (so resolver is attached to type/field defined byschema.gql
), whileImageSharpFluid
is created using vanillagraphql-js
(new GraphQLObjectType({ ... })
) which potentially doesn’t play nicely?Thought @vladar?