Skip to content
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

Warn if context values passed to createPage are different types than others or empty #4360

KyleAMathews opened this issue Mar 5, 2018 · 10 comments


Copy link

@KyleAMathews KyleAMathews commented Mar 5, 2018

Someone creating pages could run into a mysterious GraphQL error if any of the pages context has missing information:

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.

@KyleAMathews KyleAMathews added the DX label Mar 5, 2018
@m-allanson m-allanson added type: maintenance and removed DX labels Apr 13, 2018
Copy link

@mainframev mainframev commented May 7, 2018

yeah, right now have this issue, trying to fix, but without result :(

Copy link

@BerlinaLI BerlinaLI commented Jul 19, 2018

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

Copy link

@Jonqth Jonqth commented Sep 4, 2018

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 contextto be actually passed onto the template the component needs to be inside /templates

Copy link

@peterjaap peterjaap commented Nov 10, 2018

@Jonqth thanks so much for that last edit. Finally fixed this issue after hours of hunting..!

@gatsbot gatsbot bot added the stale? label Jan 30, 2019
Copy link

@gatsbot gatsbot bot commented Jan 30, 2019

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!

Copy link

@gatsbot gatsbot bot commented Feb 10, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m 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!

Copy link

@alanshortis alanshortis commented Jul 15, 2019

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.

Copy link

@tianzhich tianzhich commented Jul 21, 2019

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?

Copy link

@whalesingswee whalesingswee commented Aug 4, 2019

@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!

Copy link

@tianzhich tianzhich commented Aug 5, 2019

I solved in #15977 cause the difference between StaticQuery and page query.

Maybe it could help someone.

ShabazBadshah added a commit to ShabazBadshah/ that referenced this issue Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.