I cannot query orders in Shopify with GraphQL for ambiguous reason, I am using Shopify API version 2022-10, this is my query:
query {
orders(first: 10) {
edges {
node {
id
}
}
}
}
This is what I get
{
"errors": [
{
"message": "Field 'orders' doesn't exist on type 'QueryRoot'",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"query",
"orders"
],
"extensions": {
"code": "undefinedField",
"typeName": "QueryRoot",
"fieldName": "orders"
}
}
]
}
I made sure to check the App development permissions, read and write orders were assigned. How to solve this?
Shopify Storefront endpoint does not expose orders like this.
Alternately, you can get orders from customer - https://shopify.dev/docs/api/storefront/2022-10/objects/Customer#connection-customer-orders
If you still need to make orders query like this from the question, you have to use Admin endpoint in place of Storefront - https://shopify.dev/docs/api/admin-graphql/2022-10/queries/orders#examples-Get_the_first_10_orders