-
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
Queries from unused themes cause "gatsby develop" to fail #16338
Comments
would definitely like gatsby to do a check against gatsby-config before running stuff in node_modules for me. |
I think it's the same for source plugins too. Like |
recursive check 🤷♂️ nothing is impossible. bottom line is are you surprising your users? yes? is it likely? yes? are you telling them what to do when it happens? no? probably not good. |
This is unfortunate! We currently parse js in The reason we don’t work backwards from gatsby-config is for the ability to support queries in arbitrary dependencies (like gatsby-seo for example) The right way to solve this would be to further filter for:
|
a filter may not be the only approach available to you. i wonder if query parsing can be made lazier. right now queries are eager, which is ALSO a problem if you have a query in a file that is inside your main project but that isn't imported in anywhere, e.g. i would not expect my query inside making queries lazy would solve both this and that problem. |
If I understand Gatsby right, the way it works is that it will run all the query at build time and generates the data into static json. That’s how in prod there is no graphql server. Not sure how to parse the queries in a lazy way then. |
Yeah we don't run the queries, is the validation step. Perhaps we could store the errors for queries and only show them if we know the query is used in a component. |
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! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
the "workaround" i use is uninstalling the node module and renaming js files. i literally delete ".js" so that gatsby stops doing its thing. its not good. too magic. i hope gatsby prioritize this as its a nasty experience for beginners who run into it (and it doesnt take long to do that). |
Hitting this issue as well. @johno is there a way around this for latent shadowing? Currently shadowing a query component but this fails when the dependent theme is in |
OK I created a PR that checks for themes against Any pitfalls if unused themes are excluded from the query compiler? |
Anyone know how common this case is? Do people often have unused themes in their build? Or mostly when initially setting up? Wondering about the impact surface of this problem. |
@KyleAMathews I am being hit by this sort of error from disabled components. I would think your proposed solution would resolve my problem (whereas I suspect the linked PR would not) |
@pvdz I'm running into an issue related to this which is less breaking but possibly more common in theme development. If a theme developer allows page queries to be replaced through shadowing or other means, the original query will still show the "GraphQL query in the non-page component" warning despite the theme being used as intended. |
Hi! I'm closing this as a stale issue as in the meantime Gatsby 4 and related packages were released. You can check our Framework Version Support Page to see which versions currently receive active support. Please try the mentioned issue on the latest version (using the Thanks! |
Description
Queries from themes that aren't being used cause an app to fail. It's sort of an abrupt experience to have installing a package make your app crash when it isn't configured. I'm not sure if we should check to make sure a theme is being used or if we should error in a more friendly way that says to configure the theme or use it.
Steps to reproduce
Expected result
The blog theme runs unaffected by the docs theme which isn't configured.
Actual result
We receive an error that crashes the app:
Related
The text was updated successfully, but these errors were encountered: