Hello all,
Wanted to share a discovery I made after several HOURS of troubleshooting. When writing GraphQL queries and filtering the results, there are rules to keep in mind based on the search syntax: https://shopify.dev/docs/api/usage/search-syntax#search-query-syntax
Note Equality (
depends on how a field is indexed.
- For numeric fields, : represents equality.
- For tokenized fields, equality exists if the term is found anywhere in the field.
For non-tokenized fields, the search query string must match the searched field exactly.
Since “fulfilled” is a substring of “unfulfilled”, filtering the query by query: “fulfillment_status:<=fulfilled” will return orders which are both fulfilled and unfulfilled!
To get fulfilled orders only, going by alphabetical order, fulfilled<unfulfilled, so we’ll use the less-than-equals operator :<=, yielding the filter query: “fulfillment_status:<=fulfilled”
To get all orders that are not yet fulfilled, we can use the negation operator ‘-’, so we query: “-fulfillment_status:fulfilled”
Hope this info helps you, not only with filtering orders, but when filtering GraphQL results for other objects.