Discussing APIs and development related to customers, discounts, and order management.
Hi there,
I've recently run into an issue where the following GraphQL query isn't returning orders from a customer that are a few months old. Customers who've ordered recently are getting orders in the response.
The weird thing is, in the response I see `numberOfOrders` has the correct value, e.g 2, but the orders array is empty:
query CustomerOrders($customerId: ID!) { customer(id: $customerId) { id email numberOfOrders orders(first: 250) { edges { node { id name } } } } }
Is there some limitation I'm hitting? We really need access to a customers full order history for accurate reporting. Is this a scope or app permissions thing?
Any help would be much appreciated
All the best
Most likely https://shopify.dev/docs/api/admin-graphql/unstable/queries/order#field-order-order:
Only the last 60 days' worth of orders from a store are accessible from the Order object by default. If you want to access older orders, then you need to request access to all orders. If your app is granted access, then you can add the read_all_orders scope to your app along with read_orders or write_orders. Private apps are not affected by this change and are automatically granted the scope.