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

Why GraphQL returns undefined whereas GraphiQL returns something? #9885

Closed
Steffi3rd opened this issue Nov 12, 2018 · 2 comments
Closed

Why GraphQL returns undefined whereas GraphiQL returns something? #9885

Steffi3rd opened this issue Nov 12, 2018 · 2 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@Steffi3rd
Copy link

Steffi3rd commented Nov 12, 2018

Summary

I made a query with GraphQL and I want to display results with data but it's undefined.

console.log(data) returns undefined

capture d ecran 2018-11-12 a 13 53 41

GraphiQL

capture d ecran 2018-11-12 a 13 54 11

Relevant Information

I tried an alternative with StaticQuery and it worked.
I don't know why it doesn't work without StaticQuery

Someone can help please?

Environment

  System:
    OS: macOS 10.14
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.12.0 - /usr/local/bin/node
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 70.0.3538.77
    Safari: 12.0
  npmPackages:
    gatsby: ^2.0.24 => 2.0.43 
    gatsby-image: ^2.0.15 => 2.0.20 
    gatsby-plugin-lodash: ^3.0.1 => 3.0.2 
    gatsby-plugin-manifest: ^2.0.5 => 2.0.8 
    gatsby-plugin-offline: ^2.0.6 => 2.0.13 
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.1 
    gatsby-plugin-sharp: ^2.0.7 => 2.0.12 
    gatsby-plugin-sitemap: ^2.0.1 => 2.0.2 
    gatsby-source-prismic: ^2.0.0 => 2.1.0 
    gatsby-transformer-sharp: ^2.1.4 => 2.1.8 
  npmGlobalPackages:
    gatsby-cli: 2.4.5

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

@cwlsn
Copy link
Contributor

cwlsn commented Nov 12, 2018

On the querying with GraphQL page, it mentions if you want to query in non-page components, you do need to use <StaticQuery />.

@kakadiadarpan kakadiadarpan added the type: question or discussion Issue discussing or asking a question about Gatsby label Nov 12, 2018
@Steffi3rd
Copy link
Author

Okay so that's normal! Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants