GraphQL error: access denied (Customers)

codixir
New Member
3 0 0

I am building a public App, and wanted to get the list of all cutomers in my Development Store. But I am not able to render the list 

import React from 'react'
import gql from 'graphql-tag'
import { Query } from 'react-apollo'

const GET_CUSTOMERS = gql`
    query getCustomers {
        customers {
            edges {
              node {
                displayName
                totalSpent
              }
            }
          }
    }
`

class Customers extends React.Component {
    render() {
        return (
            <Query query={GET_CUSTOMERS}>
                {({ data, loading, error }) => {
                  if (loading) { return <div>Loading…</div>; }
                  if (error) { return <div>{error.message}</div>; }
                  
                   {
                    return data.customers.edges.map((edge) => (
                        <p key={edge.node.displayName}> {edge.node.displayName}</p>
                      ))}
                }}
            </Query>
        )
    }
}

export default Customers

I am getting `GraphQL error: access denied` . Can you help please.

0 Likes
Visely-Team
Shopify Partner
1837 210 421

Are you sure your app's token has the read_customers access scope and is correctly passed along? If you try the request from postman or curl, do you get the error?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
codixir
New Member
3 0 0
Thank you for responding.

I am not sure what you mean by ‘scopes’. I am creating my first app and that might have skipped my attention. Are there different tiers of access?
0 Likes
Visely-Team
Shopify Partner
1837 210 421
Exactly. There are different scopes for reading/updating/creating object in Shopify. Whenever you authorize your app with Shopify you provide a list of access scopes your app will be granted. More information on scopes here - https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes
Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Greg_Kujawa
Shopify Partner
965 80 205

When you first register your app in the Shopify store, the URL that pops up the "allow" form should list all the scopes your app is allowed access to. See https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes for details!

0 Likes
codixir
New Member
3 0 0
Thank you. I will try that.
0 Likes
dkukreja
New Member
3 0 0

Heyy Visely.. I am also getting same error of access denied for 'customers', I have given the permission of read_customers and write_customers to my api.. infact it is working fine while querying for  a customer with accesstoken but it is not working while I am trying to fetch the list of all customers with the 'customers' queryroot.. For 'customers' queryroot, I am getting the accesssdenied error in online graphql editor.. while in Postman I am getting "Field 'customers' does not exist on 'queryroot'"

0 Likes