profile
viewpoint

Ask questions[gatsby-source-graphql] Shopify GraphQL Schema Error

Trying to use the Shopify GraphQL endpoint results in the error: "Schema must contain unique named types but contains multiple types named "QueryRoot"."

To reproduce clone the gatsby starter and insert that gatsby-config from the original post. That's all that i've done

Shopify's GraphQL schema has multiple "roots" I guess? e.g.

{
    shop {
        name
    }
    products(first: 0) {
        edges {
            node {
                title
                descriptionHtml
            }
        }
    }
}

I'm not sure how to retrieve their exact JSON Schema to post here

Gatsby-config entry:

{
    resolve: 'gatsby-source-graphql',
    options: {
        url: 'https://' + process.env.SHOPIFY_STORE_NAME + '.myshopify.com/admin/api/graphql.json',
        headers: {
            'X-Shopify-Access-Token': process.env.SHOPIFY_ADMIN_API_KEY
        },
        typeName: 'Shopify',
        fieldName: 'shopify'
    }
}

Shopify's GraphQL Documentation: https://help.shopify.com/en/api/graphql-admin-api/getting-started

gatsbyjs/gatsby

Answer questions iamskok

@heart-of-code Thank you!

Did you make it work or it's still a draft?

<details> <summary>After fixing the import path for graphQLHelpers in plugins/gatsby-source-admin-shopify/src/nodes/metafields.js, rebuilding the plugin and running gatsby develop I get error.</summary> success open and validate gatsby-configs — 0.008 s success load plugins — 0.349 s success onPreInit — 0.006 s success initialize cache — 0.035 s success copy gatsby files — 0.056 s success onPreBootstrap — 0.006 s Query Once, attempt 2 Query Once, attempt 2 error Plugin gatsby-source-shopify-admin returned an error

Error: createNodeId must be a function, was undefined

  • create-remote-file-node.js:339 module.exports [gatsby-source-admin-shopify]/[gatsby-source-filesystem]/create-remote-file-node.js:339:11

  • file.js:55 _callee$ /Users/skok/dev/gatsby-shopify-starter/plugins/gatsby-source-admin-shopify/nodes/file.js:55:8 1

  • next_tick.js:43 _tickCallback internal/process/next_tick.js:43:7

success source and transform nodes — 0.661 s error UNHANDLED REJECTION

Error: Invariant Violation: Encountered an error trying to infer a GraphQL type for: products___NO DE. There is no corresponding node with the id field matching: "shopify__Product__Z2lkOi8vc2hvcG lmeS9Qcm9kdWN0LzUyOTc3OTc4NTc3OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0NTg5NjI0Mw ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE4NDk4NzA0ODM1MDc=,shopify__Product__Z2lkOi8vc2h vcGlmeS9Qcm9kdWN0LzE4NDk4NzA0NTA3Mzk=,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE4NDk4Njk5NTk yMTk=,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE4NDk4Njk2OTcwNzU=,shopify__Product__Z2lkOi8v c2hvcGlmeS9Qcm9kdWN0LzE0MDE4NjY5NDQ1NjM=,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzcyMTY4MDIz NjU5NQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU3MjU4MTc3MzM2Mw==,shopify__Product__Z2lkO i8vc2hvcGlmeS9Qcm9kdWN0LzU3MjU3NTYxMjk3OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0N TYzNDA5OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0Mzk5NTY5OQ==,shopify__Product__Z2 lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0MzI0MjAzNQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MT Q0MTc2NzQ3NQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjgwMDg5NDAwMw==,shopify__Product_ Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjgwMDY2NDYyNw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU 0Njc5OTM1MzkwNw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MjcyNjgzNQ==,shopify__Produ ct__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MjU2Mjk5NQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0 LzU0NjY5MjMwMDg1MQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MjE2OTc3OQ==,shopify__Pr oduct__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MjAzODcwNw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kd WN0LzU0NjY5MTkwNzYzNQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MTgwOTMzMQ==,shopify _Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MTY0NTQ5MQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm 9kdWN0LzU0NjY5MTMxNzgxMQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MTIxOTUwNw==,shopi fy__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MTA1NTY2Nw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9 Qcm9kdWN0LzU0NjY5MDk5MDEzMQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MDgyNjI5MQ==,sh opify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MDc2MDc1NQ==,shopify__Product__Z2lkOi8vc2hvcGlm eS9Qcm9kdWN0LzU0NjY5MDU2NDE0Nw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MDIzNjQ2Nw== ,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY5MDAzOTg1OQ==,shopify__Product__Z2lkOi8vc2hvc GlmeS9Qcm9kdWN0LzU0NjY4OTc3NzcxNQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4OTcxMjE3O Q==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4OTU4MTEwNw==,shopify__Product__Z2lkOi8vc2 hvcGlmeS9Qcm9kdWN0LzU0NjY4OTQxNzI2Nw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4OTIyMD Y1OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4OTA1NjgxOQ==,shopify__Product__Z2lkOi8 vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4ODg2MDIxMQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4ODY 5NjM3MQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4ODU2NTI5OQ==,shopify__Product__Z2lk Oi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4ODQ2Njk5NQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4 ODMwMzE1NQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4ODIwNDg1MQ==,shopify__Product__Z 2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4ODAwODI0Mw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0N jY4Nzk0MjcwNw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4NzgxMTYzNQ==,shopify__Product __Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjY4Nzc0NjA5OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lz UyOTc3OTc4NTc3OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0NTg5NjI0Mw==,shopify__Prod uct__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU3MjU4MTc3MzM2Mw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN 0LzU3MjU3NTYxMjk3OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0NTYzNDA5OQ==,shopify__P roduct__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0Mzk5NTY5OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9k dWN0LzU2MTQ0MzI0MjAzNQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU2MTQ0MTc2NzQ3NQ==,shopify __Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzU0NjgwMDg5NDAwMw==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qc m9kdWN0LzUyOTc4MDI3NzI5OQ==,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzUyOTc4MDA4MDY5MQ==,shop ify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE4NDk4NzA0ODM1MDc=,shopify__Product__Z2lkOi8vc2hvcGlmeS 9Qcm9kdWN0LzE4NDk4NzA0NTA3Mzk=,shopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE4NDk4Njk5NTkyMTk=,s hopify__Product__Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE4NDk4Njk2OTcwNzU=".

  • invariant.js:40 invariant [gatsby-shopify-starter]/[invariant]/invariant.js:40:15

  • add-inferred-fields.js:288 getFieldConfigFromFieldNameConvention [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/add-inferred-fields.js:288:3

  • add-inferred-fields.js:189 getFieldConfig [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/add-inferred-fields.js:189:19

  • add-inferred-fields.js:69 Object.keys.forEach.unsanitizedKey [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/add-inferred-fields.js:69:17

  • Array.forEach

  • add-inferred-fields.js:67 addInferredFieldsImpl [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/add-inferred-fields.js:67:30

  • add-inferred-fields.js:40 addInferredFields [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/add-inferred-fields.js:40:3

  • index.js:40 addInferredType [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/index.js:40:3

  • index.js:86 typeNames.map.typeName [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/index.js:86:51

  • Array.map

  • index.js:86 addInferredTypes [gatsby-shopify-starter]/[gatsby]/dist/schema/infer/index.js:86:35

  • schema.js:139 [gatsby-shopify-starter]/[gatsby]/dist/schema/schema.js:139:11

  • Generator.next

  • next_tick.js:77 process.internalTickCallback internal/process/next_tick.js:77:7 </details>

At my current company, we have to use meta fields so Storefront API is not enough. Will it be possible to chat with you about your experience making Admin & Storefront API work together?

useful!

Related questions

Error: Cannot create as TypeComposer the following value: Date. hot 3
Importing Link from gatsby breaks Storybook hot 2
Loading chunks while a new release is deployed hot 2
Webpack error #98123 when running "gatsby develop" hot 2
gatsby build error #11328 A page component must export a React component for it to be valid. Please make sure this file exports a React component: /Users/tiagosanchez/Documents/Projects/personalBlog/node_modules/gatsby-plugin-offline/app-shell.js hot 2
[gatsby-telemetry] error: src/postinstall.js not found in Linux environments hot 2
IE11: Object not valid as React Child hot 2
CircleCI build Error: spawn ENOMEM hot 2
[Help] I somehow managed to butcher my site's performance hot 2
Build gets stuck at Generating image thumbnails / Update schema on large sites hot 2
UNHANDLED REJECTION Source and destination must not be the same. hot 2
gatsby-source-shopify unable to complete build hot 2
Gatsby's Use Of Polyfills and the 'Missing Resources for x' error hot 2
Autoprefixer "browsers" option is deprecated in v9, produces warnings hot 2
&#39;gatsby&#39; is not recognized as an internal or external command hot 2
Github User Rank List