Query filters
Learn how to narrow down your GraphQL searches using Bunny's filters.
Bunny’s GraphQL API follows standard practices and allows you to page through results with first, last and cursors. But filters make it possible to get very specific in a simple way.
The admin UI’s table filters give a good idea of what’s possible as they are using the GraphQL filters. You can search for ranges, relative dates and much more. For example:
{
invoices(filter: "createdAt is after 2024-07-14") {
nodes {
number
}
}
}
You can also combine conditions.
{
accounts(filter: "createdAt is after 2024-01-14 and billingState = 'CA'") {
nodes {
name
}
}
}
Field names can be written in camelCase (billingState) or snake_case (billing_state). Text values go in single quotes.
The operators vary by data type.
| Field type | Operators | Example |
|---|---|---|
| Boolean | is, is_not |
evergreen is true |
| Number | =, !=, <, <=, >, >=, equals, not_equals |
employees >= 50 |
| Text | =, !=, equals, not_equals, begins_with, ends_with, contains, contains_not |
name begins_with 'Acme' |
| Any | in [ ], not_in [ ] |
billingState in ['CA', 'WA'] |
Text comparisons are not case-sensitive.
You can also test for empty values using is blank and is_not blank, for example billingState is_not blank.
DatesLink to Dates section
Dates have the most complex syntax and are best explained in the simplified grammar below. Dates are written without quotes, and a time must include its UTC offset.
date_condition : field (is | is_not) [on] day
| field (is | is_not) (on | before | after | on or before | on or after) date
| field (is | is_not) (current | past | next) period
| field (is | is_not) (past | next) int periods
| field (is | is_not) in int periods
| field (is | is_not) int periods ago
day : today | yesterday | tomorrow | this week | date
period : day | week | month | quarter | year
periods : day[s] | week[s] | month[s] | quarter[s] | year[s]
date : yyyy-mm-dd | yyyy-mm-ddThh:mm:ss+hh:mm
The date syntax is very powerful and allows you to easily express relative times, such as:
createdAt is todaycreatedAt is on or after 2024-10-10createdAt is before 2024-10-10T09:30:00-07:00createdAt is current monthcreatedAt is past quarter(the whole previous quarter)createdAt is past 3 monthsendDate is in 3 weeks(exactly three weeks from today)createdAt is 10 days ago(exactly ten days ago)
GroupingLink to Grouping section
The filter syntax also allows you do group expressions using parenthesis and combine them with and and or, for example:
{
accounts(filter: "annualRevenue > 100000 and (billingState = 'CA' or billingState = 'WA')") {
nodes {
id
}
}
}
Put ! in front of a group to negate it, for example !(billingState = 'CA').