-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQL Error on pages that query conditionally added SitePage fields #2685
Comments
In Gatsby v1, But there needs to be some internal changes first for this to work namely regenerating the GraphQL schema for pages after pages are added (which happens after the first time the GraphQL schema is generated). If this is something you'd like to take on, would love to get you going on a PR adding this! |
I can give it a shot! Would love any pointers you have on where to start and generally what needs to happen. |
Sweet! So basically much of the Gatsby magic is coordinated in this file https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/bootstrap/index.js What you'll want to do is to add a new bootstrap step here which now that we've collected page information, generates the full page schema (we cheat a bit and add a fake page node earlier so there's a minimal SitePage schema available earlier). The tricky this is we don't want to regenerate the full GraphQL schema again as on large sites that can start taking 500ms+ so starts getting expensive. Ideally we'd regenerate just the page type and overwrite the previously created one which should be cheap enough to do. Lemme know if you have more questions! This would be great to get in. |
Fixed in #2710. |
Repro: https://github.com/fusepilot/gatsby-page-query-conditional-field-repro
Possibly Related: #1718
I'm adding a custom field using createNodeField to certain pages of my site. I get a compile time GraphQL error unless I add the field to all pages. Everything works fine at runtime.
The relevant code:
The text was updated successfully, but these errors were encountered: