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
}
}
}
}
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?
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? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
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? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hello.
I've been looking into this as well, and I have the following query. But this query is returning all draft orders on my store. I'm at a loss and was hoping someone could verify that my query syntax was correct? I've tried various IDs and have also tried wrapping the id in '' so that it's passed through as a string, but still no luck.
Has anyone else had this issue?
query {
draftOrders(first: 12, query: "query=customer_id:4542908498104") {
edges {
node {
id
customer {
id
firstName
email
}
}
}
}
}
Okay I have found my mistake, although I'm sure I picked up the original structure from the documentation.
// Correct format
// Notice the change to the value of the query parameter.
query {
draftOrders(first: 12, query: "customer_id:4542908498104") {
edges {
node {
id
customer {
id
firstName
email
}
}
}
}
}
I hope this helps anyone who finds it, I came across this post which helped me come to this conclusion https://community.shopify.com/c/Shopify-APIs-SDKs/Syntax-for-quot-query-quot-argument-in-GraphQL-Sto...
User | Count |
---|---|
13 | |
12 | |
7 | |
4 | |
4 |