hygraph / gatsby-graphcms-ecommerce-starter

Swag store built with GraphCMS, Stripe, Gatsby, Postmark and Printful.
https://gatsby-graphcms-ecommerce-starter.netlify.com
199 stars 57 forks source link

Build fails on GraphQL query 'cms' #71

Closed domtaylor closed 4 years ago

domtaylor commented 4 years ago

yarn dev and yarn build fails due to graphql query of 'cms' in Header.js. Tried changing to align with my GraphCMS setup of my store but still fails.

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Cannot query field "ShakaSurf" on type "Query".

GraphQL request:3:5 2 | query NavQuery { 3 | cms { | ^ 4 | categories {

File: src/components/Header.js:11:5 It could be my understanding of GraphCMS and not naming my fields correctly, any pointers here greatly appreciated.

ynnoj commented 4 years ago

@domtaylor You may need to gatsby clean to clear the cached schema from the project. This will happen often when adding new fields and models to your GraphCMS project.

notrab commented 4 years ago

Hi @domtaylor

We're updating the README to reflect some of the easier setup.

FYI, you can "Create a new project" from GraphCMS and select the SWAG Store in the modal, which should clone all the fields necessary.

domtaylor commented 4 years ago

oh that makes total sense! Thanks Jonathan I'll try that.

domtaylor commented 4 years ago

@notrab cheers for this. I'll think I'll have to start again with the Swag store template, I think I chose storefront last time

ynnoj commented 4 years ago

@domtaylor Did you get your issue resolved?

domtaylor commented 4 years ago

@ynnoj so I tried using the SWAG template and cleared out cache and public directories, but build still fails on the 'cms' query. here's my setup: System: OS: macOS 10.14.6 CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.0 - /usr/local/opt/node@10/bin/node Yarn: 1.6.0 - ~/.yarn/bin/yarn npm: 6.4.1 - /usr/local/opt/node@10/bin/npm Languages: Python: 3.7.0 - /usr/local/bin/python Browsers: Chrome: 79.0.3945.130 Firefox: 69.0 Safari: 13.0.4 npmPackages: gatsby: 2.18.12 => 2.18.12 gatsby-image: ^2.2.33 => 2.2.33 gatsby-plugin-postcss: 2.1.13 => 2.1.13 gatsby-plugin-purgecss: 4.0.1 => 4.0.1 gatsby-plugin-react-helmet: ^3.1.18 => 3.1.18 gatsby-plugin-react-svg: 3.0.0 => 3.0.0 gatsby-plugin-sharp: ^2.3.3 => 2.3.3 gatsby-source-filesystem: ^2.1.42 => 2.1.42 gatsby-source-graphql: 2.1.20 => 2.1.20 gatsby-source-printful: 1.2.0 => 1.2.0 gatsby-transformer-sharp: ^2.3.5 => 2.3.5 npmGlobalPackages: gatsby-cli: 2.8.1 gatsby-source-filesystem: 2.0.36

domtaylor commented 4 years ago

@ynnoj Just tried again with --verbose and get this error: ERROR #11321 PLUGIN

"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:

[object Object]

ynnoj commented 4 years ago

@domtaylor Can you share your gatsby-config.js? Particularly the configuration for gatsby-source-graphql.

Does the build fail if you remove that query?

domtaylor commented 4 years ago

@ynoj sure, it's not changed from yours. Build still fails with query removed with the following Error: Invariant Violation: gatsby-source-graphql requires either option url or creat eLink callback. https://gist.github.com/domtaylor/5cde6d47d2010927c91f51aa0d0262d3

I have set Auth Tokens(Open and Query) in Gatsby CMS and specified in .env

ynnoj commented 4 years ago

gatsby-source-graphql requires either option url or createLink callback

@domtaylor Sounds like the value passed to url is undefined?

domtaylor commented 4 years ago

@ynnoj Ah I think I know the issue. This has happened before with process.env I think it's a webpack issue and can be fixed with renaming .env to .env.development

ynnoj commented 4 years ago

@domtaylor Sounds like you're all sorted?!

domtaylor commented 4 years ago

@ynnoj yep all good. Thanks!