GraphQL Error: Field 'codeDiscountNodes' doesn't exist on type 'QueryRoot'

Highlighted
Shopify Partner
5 0 0

Hi all,

I am currently using the official shopify node modules, and I am stuck on this error.

The snippet of code is this one here:

shopify = new Shopify({
shopName: shopname,
accessToken: accessToken
})
console.log(client[0].accessToken)
result = await shopify.graphql(query)

If I use this query (simplified query here):

{
   codeDiscountNodes (first:10) {
      pageInfo {
         hasPreviousPage
         hasNextPage
      }
   }
}

The error Field 'codeDiscountNodes' doesn't exist on type 'QueryRoot' comes out.  If I change codeDiscountNodes into something else like automaticDiscountNodes, it returns successfully.  Scope includes read and write discounts.  This query works on the GraphQL Shopify App.

Any help would be really appreciated.

Thanks

0 Likes
Highlighted
Shopify Staff
Shopify Staff
496 64 111

Hey @ostalks,

Strange that it works in GraphiQL but not your app. Can you provide the full query that's not working? As well, can you make the call again and provide a rough timeframe for when you did that, along with the shop_id. I'll use this to check our logs and see what came through on this end.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
5 0 0

Hi @_JB ,

I added apiVersion '2020-07' to the parameters (instead of letting it use the default apiVersion selected by the library).  The problem disappeared and now works as expected.  It might be a glitch somewhere in the apiVersion used by default by the node library.

0 Likes