Filtering
Pylo's filter system lets you build complex queries with AND/OR logic and a comprehensive set of operators.
Filter Structure
Filters are passed to list queries via the filter input:
query
1
2
3
4
5
6
7
8
9
10
query {
customerList(
filter: {
query: [{ /* conditions */ }]
sortby: [{ /* sort rules */ }]
}
) {
data { id name }
}
}Conditions
Each condition specifies a field, operator, and value:
condition
1
2
3
4
5
6
7
{
condition: {
field: "name"
operator: ilike
value: "%john%"
}
}Available Operators
String Operators
| Operator | Description | Example |
|---|---|---|
ilike | Contains (case-insensitive) | %search% |
like | Contains (case-sensitive) | %search% |
notiLike | Does not contain (case-insensitive) | %exclude% |
notLike | Does not contain (case-sensitive) | %exclude% |
startsWith | Starts with | prefix |
endsWith | Ends with | suffix |
equal | Exact match | value |
notEqual | Not equal | value |
Numeric & Date Operators
| Operator | Description |
|---|---|
equal | Equal to |
notEqual | Not equal to |
greaterThan | Greater than |
lessThan | Less than |
greaterThanOrEqual | Greater than or equal |
lessThanOrEqual | Less than or equal |
Null & Empty Operators
| Operator | Description | Requires Value |
|---|---|---|
isNull | Field is null | No |
isNotNull | Field is not null | No |
isEmpty | Field is empty string | No |
isNotEmpty | Field is not empty | No |
Boolean Operators
| Operator | Description | Requires Value |
|---|---|---|
isTrue | Field is true | No |
isFalse | Field is false | No |
List Operators
| Operator | Description | Uses |
|---|---|---|
in | Value in list | values array |
notIn | Value not in list | values array |
AND Conditions
query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
query {
customerList(
filter: {
query: [{
and: [
{
condition: {
field: "status"
operator: equal
value: "active"
}
}
{
condition: {
field: "created_at"
operator: greaterThan
value: "2024-01-01"
}
}
]
}]
}
) {
data { id name status created_at }
}
}OR Conditions
query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
query {
customerList(
filter: {
query: [{
or: [
{
condition: {
field: "status"
operator: equal
value: "active"
}
}
{
condition: {
field: "status"
operator: equal
value: "pending"
}
}
]
}]
}
) {
data { id name status }
}
}Filtering Relations
Use dot notation to filter by related fields:
query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
query {
orderList(
filter: {
query: [{
condition: {
field: "customer.name"
operator: ilike
value: "%acme%"
}
}]
}
) {
data {
id
total
customer {
data { name }
}
}
}
}Sorting
query
1
2
3
4
5
6
7
8
9
10
11
12
query {
customerList(
filter: {
sortby: [
{ field: "status", order: asc }
{ field: "created_at", order: desc }
]
}
) {
data { id name status created_at }
}
}Sort by related fields using dot notation:
query
1
2
3
4
5
6
7
8
9
10
11
query {
orderList(
filter: {
sortby: [
{ field: "customer.name", order: asc }
]
}
) {
data { id customer { data { name } } }
}
}