Can I access orders, customers, fulfillmentinfo etc. objects using storefront api ?

Highlighted
New Member
6 0 0

Hello there,

 

I am using shopify's storefront api to implement tracking order feature on my website. But, while using one of the storefront-api-examples, I am getting  "Field 'orders' doesn't exist on type 'QueryRoot'" or similar kind of errors. The orders, customer & all other objects are there in shopify's storefront api. But, error is saying that that object is not existed on 'QueryRoot'. Kindly help me out with this issue, so that I can use storefront api successfully. 

 

Thanks in advance,

Vivek

0 Likes
Shopify Staff
Shopify Staff
1558 77 232

Order objects exist on customers via the Storefront API. The Storefront API is meant to be used by a client that emulates a storefront, meaning anything you can see on a typical storefront (including through which paths you would access these resources) is similar to the actual storefront.

 

https://help.shopify.com/en/api/storefront-api/reference/object/customer

 

Cheers.

0 Likes
New Member
6 0 0

Hi Alex, thanks for the quick response. Actually, I have gone through the docs already by myself. But, I am not able to access any objects like customer, order, etc. through that. So, any clear example can be very helpful for me to access those object using storefront api using graphql.


@Alex wrote:

Order objects exist on customers via the Storefront API. The Storefront API is meant to be used by a client that emulates a storefront, meaning anything you can see on a typical storefront (including through which paths you would access these resources) is similar to the actual storefront.

 

https://help.shopify.com/en/api/storefront-api/reference/object/customer

 

Cheers.


 

0 Likes
Shopify Staff
Shopify Staff
1558 77 232

But, I am not able to access any objects like customer, order, etc. through that.

What do you mean by this?

 

... any clear example can be very helpful for me to access those object using storefront api using graphql.

Here's an example flow I'm using which I'm finding success with:

 

# First, create a customer access token for access to the customer's information (logging in)

mutation createCustomerAccessToken($input: CustomerAccessTokenCreateInput!){
  customerAccessTokenCreate(input: $input) {
    customerAccessToken {
      accessToken
      expiresAt
    }
  }
}
# Second, get the information off the customer using the customer access token

query {
  customer(customerAccessToken: "cb915f48c4d4b46ec2bf9949488120e2") {
    orders(first:10) {
      edges {
        node {
          id
        }
      }
    }
  }
}

CustomerAccessTokenCreate documentation: https://help.shopify.com/en/api/storefront-api/reference/mutation/customeraccesstokencreate

 

I hope that helps.

 

Cheers.

0 Likes