GraphQL - how do I know what's queryable?

Solved
Highlighted
Excursionist
21 0 6

This does not work:

 

{
  customers(first:10, query:"hasNote:true") {
    pageInfo {
      hasNextPage
    }
    edges {
      node {
        id,
        firstName,
        ordersCount,
        note,
        hasNote
      }
    }
  }
}

It returns records no matter what is in the 'hasNote' field.

 

It is listed in the GraphQL "Queryable Objects" documentation in the customer "fields" list:
https://help.shopify.com/en/api/graphql-admin-api/reference/object/customer

 

Yet, like a number of 'queryable objects' I've attempted to query, it does not work. Am I missing something, or is the API missing something?

Thanks

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
491 97 88

This is an accepted solution.

Hi @nathanp 

 

The queryable filter params are always in the docs. Although, hasNote is a field on Customers, it is not listed for filtering. This means you can return that, but not query based on it. Here is a direct link that should clear things up for you: https://help.shopify.com/en/api/graphql-admin-api/reference/queryroot#customers-2019-10

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


0 Likes
Highlighted
Excursionist
21 0 6

HI @vix 

 

Why then is the document I originally referenced in 'Queryable Objects':

 

Take a look: https://help.shopify.com/en/api/graphql-admin-api/reference/object/customer

 

Right across the top of the page: "Developer resources > GraphQL Admin API > API reference > Queryable objects > Customer"

 

Listing fields that are, for the most part, not queryable at all in a section titled Queryable objects is not cool.

Assuming I then go looking for a second document, the one you referenced, that has the 'actual' queryable properties of the aforementioned Queryable objects is also not cool. 

 

The Shopify GraphQL docs are unclear/inconsistent/lacking. See:

https://community.shopify.com/c/Shopify-APIs-SDKs/Syntax-for-quot-query-quot-argument-in-GraphQL-Sto...

 

https://community.shopify.com/c/Shopify-Discussion/How-to-get-customer-s-orders-and-sort-by-date-in-...

 

Too many people burning too much time having to second guess your API hurts...

1 Like
Highlighted
Shopify Staff
Shopify Staff
491 97 88

Hey @nathanp  

 

I understand your confusion here, the object Customers is queryable, which is why you can see this on that list. Within each object there are different fields. I find this to be a really great explanation: https://graphql.org/learn/schema/

 

These fields are available on the object to be returned, and you can add them into your query to see the results. However, if you are looking to query / filter, you will need to use the ones listed in the filter section. Each object and sub-object states this. For example in your link, you can see Customers has Orders, which can be then filtered based on different params: 

09-42-nhbfw-xxwwg

 

Hope that helps

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


0 Likes
Highlighted
Excursionist
21 0 6

Yes, bad documentation is confusing.

 

This is good GraphQL documentation: https://developer.github.com/v4/

 

This is the general consensus on Shopify's GraphQL documentation: "I don't understand why the Shopify documentation is so insanely horrific."

https://community.shopify.com/c/Shopify-APIs-SDKs/Syntax-for-quot-query-quot-argument-in-GraphQL-Sto...

 

I concede that I am, indeed, confused by mediocrity.

0 Likes