Someone creating pages could run into a mysterious GraphQL error if any of the pages context has missing information:
Errors:
GraphQLError: Variable "$slug" of required type "String!" was not provided.
This is hard for someone new to Gatsby to debug. We should check against this and warn.
yeah, right now have this issue, trying to fix, but without result :(
i encounter this issue and found out it is because i didnot write slug in graphql query in the create page function in my gatsby node file
Hi @KyleAMathews wanted to know if there's any update on this.
I'm using a starter for dato, my request in gatsby-node.js
work just fine with gatsby develop
although the error is till log when building.
When i try gatsby build
the same exact error you mentioned pops up, as if there's no context provided to my request.
__EDIT__: So, not so long after posting this i found that the problem came from overriding what createPage()
does in gatsby-node.js
by having my components inside /pages
when for the context
to be actually passed onto the template the component needs to be inside /templates
@Jonqth thanks so much for that last edit. Finally fixed this issue after hours of hunting..!
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY
. Please feel free to reopen this issue or create a new one if you need anything else.
Thanks again for being part of the Gatsby community!
I have run into this error today - when creating pages from a folder of .mdx
files, I was defining a component in createPage
that lives in my src/pages
folder. Moving my post component to src/components
avoids it.
Any reason this should be the case? It's not a big deal, but I'd prefer to have the component in my pages folder since it's creating pages.
All pages are created as expected, I just get this error.
I have run into this error when migrating from v1 to v2, the context values passed to createPage are same types and not null.
Anyone have same problems?
@tianzhich I was able to fix the problem after moving my post to /src/components
instead of using it inside /src/pages
as @alanshortis mentioned. Thanks!
I solved in #15977 cause the difference between StaticQuery and page query.
Maybe it could help someone.
Most helpful comment
Hi @KyleAMathews wanted to know if there's any update on this.
I'm using a starter for dato, my request in
gatsby-node.js
work just fine withgatsby develop
although the error is till log when building.When i try
gatsby build
the same exact error you mentioned pops up, as if there's no context provided to my request.__EDIT__: So, not so long after posting this i found that the problem came from overriding what
createPage()
does ingatsby-node.js
by having my components inside/pages
when for thecontext
to be actually passed onto the template the component needs to be inside/templates