We are thrilled to announce that our GraphQL API filters now support OR and Filter Groups, in addition to the previously supported AND. This new capability provides developers with more flexibility, allowing them to create more sophisticated filtering options in their applications.
With the new filter options, users can now filter for orders that meet either one of two conditions or both. The Filter Groups feature allows users to group multiple conditions together and apply them to a query.
Let’s take a look at an example with our TacoSoft orders table:
To query this data to get all orders with status “ordered” that are more than $10, we would have a graphQL query like this:
Up until now, the API only supported implicit AND filtering, defined by the separate filters in an array.
With the introduction of OR filtering, we can now define filters that work when any condition is met. For example, the following filter will return any orders over the last 30 days with the status "ordered" or "delivered":
We can create filter groups with multiple filters using both AND and OR, like this:
AND always takes precedence over OR. In the above example, we are saying <span class="code-exp">(status = ordered AND total_price > 100) OR tacos_ordered < 1</span>.
OR filters are available anywhere we support filtering in the GraphQL API.
Further reading
- How to build a Snowflake API
- Propel UI Kit: Data visualization and dashboard React components
- 5-Minute demo: How to expose your Snowflake data via a blazing-fast GraphQL API
If you don’t have a Propel account yet, you can try Propel for free and start building data apps and customer-facing analytics.