Gatsby: Error in gatsby-source-shopify

Created on 20 Jun 2019  路  6Comments  路  Source: gatsbyjs/gatsby

Description

I am getting the following error during npm run develop:

gatsby-source-shopify/<shop-name> starting to fetch data from Shopify
error
error an error occured while sourcing data
error - 
  message:   access denied
  locations: 
    - 
      line:   4
      column: 7
  path: 
    - shop
    - blogs
error query: 
  """

      query GetBlogs($first: Int!, $after: String) {
        shop {
          blogs(first: $first, after: $after) {
            pageInfo {
              hasNextPage
            }
            edges {
              cursor
              node {
                id
                title
                url
              }
            }
          }
        }
      }

  """
variables: 
  first: 250
  after: null

Steps to reproduce

Create a Storefront API Access Token that doesn't have access to "Read content like articles, blogs, and comments" and try to run gatsby

Expected result

Site builds with only the queries I provide and successfully builds.

Actual result

Unknown query is running and erroring. No where in my site am I running this query so I wouldn't expect it to run. My site doesn't need blogs from Shopify. The error is expected, the fact that it is running is not.

Environment

System:
OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
CPU: (8) x64 AMD EPYC 3251 8-Core Processor
Shell: 4.4.19 - /bin/bash
Binaries:
Node: 12.2.0 - ~/.nvm/versions/node/v12.2.0/bin/node
npm: 6.9.0 - ~/.nvm/versions/node/v12.2.0/bin/npm
npmPackages:
gatsby: ^2.9.4 => 2.9.4
gatsby-image: ^2.1.4 => 2.1.4
gatsby-plugin-manifest: ^2.1.1 => 2.1.1
gatsby-plugin-offline: ^2.1.3 => 2.1.3
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-sharp: ^2.1.5 => 2.1.5
gatsby-source-filesystem: ^2.0.39 => 2.0.39
gatsby-source-graphql: ^2.0.19 => 2.0.19
gatsby-source-shopify: ^2.0.32 => 2.0.32
gatsby-transformer-sharp: ^2.1.21 => 2.1.21
npmGlobalPackages:
gatsby-cli: 2.6.7

good first issue help wanted

All 6 comments

gatsby-source-shopify doesn't currently have any way to limit what it queries for, so your token should have rights to access everything that it's trying to fetch.

It's possible to add this as configuration to gatsby-source-shopify, it could be something like:

fetchCollections: [`ARTICLES`, `BLOGS`, `PRODUCTS`]

We'd love a PR with this feature, I wonder if you would be interested in doing it :)

Thank you for using Gatsby! :purple_heart: :muscle:

Thanks for the reply but I鈥檓 curious, why is the plugin fetching anything? Isn鈥檛 it just a data access plugin that lets me make queries? Why does it need blog posts if I never make a query for blog posts?

@altano Gatsby source plugins generally fetch all available data. We can't know what data is needed, because the data might become required due to some transformer plugins in later stages.

gatsby-source-shopify doesn't currently have any way to limit what it queries for, so your token should have rights to access everything that it's trying to fetch.

It's possible to add this as configuration to gatsby-source-shopify, it could be something like:

fetchCollections: [`ARTICLES`, `BLOGS`, `PRODUCTS`]

We'd love a PR with this feature, I wonder if you would be interested in doing it :)

Thank you for using Gatsby! 馃挏 馃挭

@freiksenet I did it a try!
Would you mind reviewing this PR ?

Thanks in advance

@martingtheodo Thank you for this PR! Let's continue talking there, I'll be closing this issue.

Fix published in [email protected] thanks to @martingtheodo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  路  3Comments

andykais picture andykais  路  3Comments

timbrandin picture timbrandin  路  3Comments

ghost picture ghost  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments