0
votes

I got this error to fetch orders with '@shopify/koa-shopify-auth'.

[GraphQL error: access denied]

The query is like this.

query {
  orders(first:2) {
    edges {
      node {
        id
        name
      }
    }
  }
}

I set below scopes.

  server.use(
    createShopifyAuth({
      apiKey: SHOPIFY_API_KEY,
      secret: SHOPIFY_API_SECRET_KEY,
      scopes: [
        'read_products','write_products',
        'read_orders', 'write_orders', 'read_all_orders',
        'read_script_tags', 'write_script_tags'
      ],
      afterAuth(ctx) {
        const { shop, accessToken } = ctx.session;
        ctx.cookies.set('shopOrigin', shop, {
          httpOnly: false,
          secure: true,
          sameSite: 'none'
        });
        ctx.redirect('/');
      },
    }),
  );

Whereas I could get product info. In addition, I could get order information via GraphiQL App.

I researched the problem, I couldn't get any clues. Do you have the same problem?

1

1 Answers

0
votes

I got the reasons.

1st- I have to add reverse: true into GraphQl like below.

  orders(first: 2 reverse: true) {
    edges {
      node {
        id
        name
      }
    }
  }
}

2nd - I needed to restart and update app after adding 'read_orders', 'write_orders'permmissions.

Thanks!