GraphQL error: Access denied for orders field.

daniel1803
New Member
2 0 0

I've got this error to fetch orders with react-apollo.

 

the query:

 

query {
  orders(first: 100, query: "financial_status:partially_refunded OR financial_status:refunded" ) {
    edges {
      node {
        name
        customer {
          firstName
          lastName
        }
        totalReceivedSet {
          shopMoney {
            amount
          }
        }
        refunds {
          totalRefundedSet {
            shopMoney {
              amount
            }
          }
        }
      }
    }
  }
}

 

 

 

my configurations are going like this:

 

 

function userLoggedInFetch(app) {
  const fetchFunction = authenticatedFetch(app);

  return async (uri, options) => {
    const response = await fetchFunction(uri, options);

    if (
      response.headers.get("X-Shopify-API-Request-Failure-Reauthorize") === "1"
    ) {
      const authUrlHeader = response.headers.get(
        "X-Shopify-API-Request-Failure-Reauthorize-Url"
      );

      const redirect = Redirect.create(app);
      redirect.dispatch(Redirect.Action.APP, authUrlHeader || `/auth`);
      return null;
    }

    return response;
  };
}

function MyProvider(props) {
  const app = useAppBridge();

  const client = new ApolloClient({
    fetch: userLoggedInFetch(app),
    fetchOptions: {
      credentials: "include",
    },
  });

  const Component = props.Component;

  return (
    <ApolloProvider client={client}>
      <Component {...props} />
    </ApolloProvider>
  );
}

class MyApp extends App {
  render() {
    const { Component, pageProps, host } = this.props;
    return (
      <AppProvider i18n={translations}>
        <Provider
          config={{
            apiKey: API_KEY,
            host: host,
            forceRedirect: true,
          }}
        >
          <MyProvider Component={Component} {...pageProps} />
        </Provider>
      </AppProvider>
    );
  }
}

 

 

 

Thanks for help

Replies 0 (0)