draftOrders(first: 10, query:"email:bob.slydell@example.com") does not work

Highlighted
New Member
3 0 0

I followed a Shopify sample, which is used to "get the first 10 draft orders associated with a customer email"

{
  draftOrders(first: 10, query:"email:bob.slydell@example.com") {
    edges {
      node {
        id
        email
      }
    }
  }
}

haupham_0-1600934407211.png

Therefore, this query should return orders associated with customer email "bob.slydell@example.com". However, the result was strange since it seemed to return all orders regardless order's email. It not only returned orders associated with customer email "bob.slydell@example.com", but also returned orders with other emails like null etc.

People can test it at: https://shopify.dev/docs/admin-api/graphql/reference/object/draftorder#status-2020-07

So is querying with email in DraftOrders broken?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
152 20 26

Hey @haupham 

If you take a look at our GraphQL query root documentation, you will see that "email" is not a valid field to query on. See here for reference: https://shopify.dev/docs/admin-api/graphql/reference/queryroot

According to that doc, you can filter on a `customer_id`. I will see about getting the invalid query removed from the sample section you pointed out. Thanks for bringing this to our attention. 

Kevin_A | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
3 0 0

So do you mean that I cannot filter DraftOrders based on customer email?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
152 20 26

Hey @haupham 

You can filter on email for orders, but not for draft orders. If you are able to get the customer ID associated with an email, you can filter based on that ID with draft orders. 

Kevin_A | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes