Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
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
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
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.
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