[gatsby-source-contentful] Errors due to missing fields in GraphQL schema
See original GitHub issueSuddenly ran into issues building and running my site with gatsby-source-contentful. I get several different errors, all of which stem from this error which occurs after the success update schema
step:
GraphQL Error There was an error while compiling your site's GraphQL queries.
Invariant Violation: GraphQLParser: Unknown field `file` on type `heroImage_2`. Source: document `BlogPosts` file: `GraphQL request`.
To explain this error, I have a field HeroImage
on my content type in Contentful. Previously, I could access the file and url through a graphql request as follows:
heroImage{
file {
url
}
}
Now, however, I cannot access the file and url, but I can only access a sys
field on HeroImage_2. Why would this change? Is this based on the data coming through from Contentful?
The errors I see when building + developing my site:
When trying to deploy my site, I get the following error:
6:19:03 PM: error Building static HTML for pages failed
6:19:03 PM: See our docs page on debugging HTML builds for help https://goo.gl/yL9lND
6:19:03 PM:
6:19:03 PM: Error: Module build failed: SyntaxError: Unexpected end of JSON input
6:19:03 PM:
6:19:03 PM: - JSON.parse
6:19:03 PM:
6:19:04 PM: - index.js:4 Object.module.exports
6:19:04 PM: [repo]/[json-loader]/index.js:4:49
6:19:04 PM:
6:19:04 PM: - @ ./.cache/sync-requires.js 37:13558-13667
6:19:04 PM:
When running gatsby develop
locally I get this error:
ERROR Failed to compile with 2 errors 18:45:22
error in ./.cache/json/file-path-file-name.json
Syntax Error: Unexpected end of JSON input
at JSON.parse (<anonymous>)
@ ./.cache/sync-requires.js 38:22893-23025
```.
This has happened twice today, and the first time it seemed to fix itself. But it's come back now and I don't know how to move forward in debuggging this.
Why would the GraphQL schema that Gatsby is referencing change when my content type in Contentful has not? Is this possibly an issue from Contentful themselves?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Troubleshooting Common Errors - Gatsby
If the data you are requesting in a GraphQL query differs from what has been sourced in the GraphQL schema you might encounter...
Read more >Gatsby Contentful - GraphQL query error: Unknown type ...
There was an error in your GraphQL query: Unknown type "ContentfulFixed". ... type your GraphQL schema if you want to use optional fields....
Read more >GraphQL: The Case of the Missing Fields - Thoughtbot
After a detailed interview with this witness, we noticed that its version of the schema was also missing the new GraphQL fields. We...
Read more >Gatsby Changelog | 5.3.0
The GraphQL schema: Changes to sort and aggregation fields change enables lower resource usage (significantly reduced memory usage) and faster “Building ...
Read more >Federation error codes - Apollo GraphQL Docs
When Apollo Gateway attempts to compose the schemas provided by your subgraphs ... EXTERNAL_ARGUMENT_MISSING, An @external field is missing some arguments ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, attempting to link to unpublished media with the Delivery token in Contentful is the source of the problem here. Terribly hard to figure that out though, maybe there should be something about that in an FAQ for Gatsby and Contentful.
It’s very strange, I don’t usually see it in
gatsby develop
, but it’s happening consistently on Netlify when building the site for deployment. Restarting thegatsby develop
process seemed to fix it, but I’m not sure why. Maybe some sort of caching issue around the Contentful schema?