Field ‘orders’ doesn’t exist on type ‘QueryRoot’ Shopify

Field ‘orders’ doesn’t exist on type ‘QueryRoot’ Shopify


0

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?

Share

1 Answer
1

Reset to default


0

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

query {
  customer(customerAccessToken: "customer_token") {
    id
    firstName
    lastName
    email
    phone
    orders (first: 10) {
      id
    }
  }
}

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

Share



Not the answer you're looking for? Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *