-
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 Errors for unused templates #11278
Comments
Sooner than later yes as themes will be able to define the schema they expect to exist. /cc @freiksenet @ChristopherBiscardi |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! Thanks for being a part of the Gatsby community! 💪💜 |
silly gatsbot. keep this open while we work on the data abstractions. |
Is there a solution for this yet? |
We released support for "schema customization" API ( https://www.gatsbyjs.org/blog/2019-03-18-releasing-new-schema-customization/ ) that allow you to define types, so schema is consistent even without having any data. Can you provide more information what kind of sources are you using, as examples of this might be different depending on what you are using. |
@pieh That sounds like a solution, but I don't unterstand how I would implement this. I have projects A and B, both using my theme. In the theme I have a query fragment for a component
Project A does have a newsletter configuration. Project B does not (and does not use the newsletter component). So in the graphql schema the |
Idea is that you would use something like this: exports.sourceNodes = ({ actions }) => {
actions.createTypes(`
type Newsletter {
endpoint: String
mail: String
}
type DirectusProject implements Node {
newsletter: Newsletter
}
`)
} so even if newsletter field is never used - it will be created in schema correctly and queries don't break. Ultimately it would be ideal if Directus plugin would create those types automatically (if it knows the type structure), so users don't have to do that manually. But this is new feature and we are stillworking on it, so it will take some time for ecosystem to catch up. |
Sorry, random click - I didn't mean to close it. |
This solves my problem, thank you! |
So are we good to close this issue now @pgegenfurtner ? |
Yes |
Sorry, I have to reopen this. In the project where the newsletter field is present, the createTypes function seems to override it with null values. What am I doing wrong here? I implemented the function in my theme. |
@pgegenfurtner Hm, that shouldn't happen. What is value that's present in the newsletter? I wonder if it'd be possible for you to share a reproduction project with us. |
Ping @pgegenfurtner |
The value is just null.
|
@pgegenfurtner That looks like it should work. Could you also include data that's inside DirectusProject type? |
Closing this because the problem described in here is solved by defining a schema using the schema customisation API. With respect to not warning for unused templates, let's track that in #20413 Thanks! |
Description
Using the new theme functionality, I have a core theme from which I generate multiple different projects, which consume this theme.
In the core theme I have different page templates. Some may not be used by theme consumers. But data which these unused templates want to query may not be available in a theme consumer, so I get a graphql error and the site cannot be build.
Is there some way around this?
The text was updated successfully, but these errors were encountered: