Graphql data query is undefined

Solved
4Akera
Tourist
7 1 1

Hello, I am developing an app for shopify platform. After following tutorial on how to set up node environment, I've tried to make a request to the graphql  API. However, the data response were undefined. I am not sure why.

Appollo setup

const client = new ApolloClient({
  fetch: fetch,
  fetchOptions: {
    credentials: "include",
    headers: {
      'Content-Type': 'application/graphql',
    }
  },
});

 

This request actually receive  data

query ($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on Collection {
      id
      
    }
  }
}

 

 However this returns undefined

query ($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on Collection {
      id
      products(first: 10) {
        edges {
          cursor
          node {
            id
            images(first: 4) {
              edges {
                cursor
                node {
                  id
                  src
                }
              }
              pageInfo {
                hasNextPage
                hasPreviousPage
              }
            }
          }
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
        }
      }
    }
    ... on Product {
      id
      images(first: 4) {
        edges {
          cursor
          node {
            id
            src
          }
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
        }
      }
    }
  }
}

 

Thanks for helping

0 Likes
4Akera
Tourist
7 1 1

This is an accepted solution.

I was able to solve it by doing separate quires for collections and products. now I must query data twice to get a result.

Also, I've turned on permissions to access products and channels in shopify admin page.

0 Likes