Wp-graphql-woocommerce: Order query is returning null

Created on 22 Oct 2020  路  3Comments  路  Source: wp-graphql/wp-graphql-woocommerce

Describe the bug
I'm trying to extract a particular order via Postman but it's returning a null order. However, when trying to query via GraphiQL, it works as expected.

Query:

query Orders {
  order(orderId: 7400) {
    orderId
    metaData {
      key
      value
    }
    billing {
      firstName
      address1
      address2
      postcode
      state
      phone
      email
      country
      company
      city
    }
    lineItems {
      nodes {
        product {
          name
          productId
          productCategories {
            edges {
              node {
                name
              }
            }
          }
          productTags {
            nodes {
              name
            }
          }
        }
      }
    }
  }
}

Expected behavior
Should return order

Screenshots
Screenshot 2020-10-22 at 1 52 51 PM

Most helpful comment

@jacobarriola @kidunot89 I see. Thank you for the explanation

All 3 comments

Sounds like you need to add authentication, since the Order type isn't publicly accessible. It works in your GraphiQL because you're logged into WordPress while making those queries.

@pmventura The orders root-level query is inaccessible for unauthenticated users. If the order was made by a guest, the user need at least a session token to query their own orders, and the billing email must be set on the session. You can set it with the updateCustomer() mutation.

@jacobarriola @kidunot89 I see. Thank you for the explanation

Was this page helpful?
0 / 5 - 0 ratings