Out now! Check out the Poll results: Do you have a Shopify store?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

VRiya1327
Tourist
10 0 2

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

Replies 3 (3)

Alex
Shopify Staff
1561 81 343

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.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

VRiya1327
Tourist
10 0 2

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.


 

Alex
Shopify Staff
1561 81 343

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.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog