-
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 does not seem to be working on templates #1911
Comments
Any console error? |
@KyleAMathews no console errors, just the console.logs however, on some refreshes i do get an 'invariant violation'
|
I might me misunderstanding, but it looks as though you're treating the templates more as components or pages and not "page templates." I think templates will only perform the queries if they go through a I'm not sure if components can make their own queries, but what you might want to do is write them to take in the data, and then perform the query on a page (like index, about, etc) where you can then pass the queried data down to that component. |
@markmichon you are correct, I was using that wrong. Making the query from the index.js page fixed it. Although, the documentation is confusing, since it describes graphQL queries being made from pages/templates/layouts |
templates are "page templates". If the docs don't make that clear, we'd appreciate a PR making the distinction clearer! |
Node Version : v8.4.0
npm version: v5.3.0
OS: ArchLinux
uname -r
: 4.12.8-2-ARCHTrying to query stuff from siteMetadata in one of my templates: https://github.com/ScrantonHacks/website/tree/master/src/templates/SocialShare
but it keeps coming back as undefined. Tried asking in the Gatsby discord, we couldn't seem to figure it out. My GraphQL query comes back fine in the GraphIQL
Not sure what the problem is.
gatsby-config.js
package.json
have not modified any other config files.
The text was updated successfully, but these errors were encountered: