Error when requesting company metafields in Admin extension

I got this error each time I try to retrieve metafields of a company in Admin extension (block and action)

"Internal error. Looks like something went wrong on our end.\nRequest ID: 376add74-344f-495e-9377-38a7342e25e5-1740473794 (include this in support requests).

Here is the query string :

const getCompanyQuery = {
    query: `query DraftOrder($id: ID!) {
      draftOrder(id: $id) {
        id
        purchasingEntity {
          ... on Customer {
            id
          }
          ... on PurchasingCompany {
            company {
              id
              metafields(first: 30) {
                edges {
                  node {
                    namespace
                    key
                    value
                  }
                }
              }
            }
          }
        }
      }
    }`,
    variables: {id: data.selected[0].id},
  }

Can Shopify staff help check if this is a bug on Shopify’s internal? Or was that my query is malformed?

Nevermind, solved by adding read_companies scope to the app access scope.

The documentation here (Shopify API access scopes) does not mention about the existence of the scope read_companies at all. (It only mentions customer_read_companies for customer account API, which this scope also does not work for admin extension).

To access companies via Admin GraphQL, you need to use “read_companies” scope. Hope this can help future readers.

Shopify should mention that “read_companies” scope is required, instead of just saying internal error.

This documentation mentioned “read_customers” OR “read_companies” are required.

You need both for it to work.

Thanks for flagging this - will connect with our dev docs team to clarify this.

1 Like