query {
allPosts(filter: {
body: { isNull: true }
}) {
...
}
}
query {
allPosts(filter: {
body: { isNull: false }
}) {
...
}
}
query {
allPosts(filter: {
createdAt: { greaterThan: "2021-01-01" }
}) {
...
}
}
query {
allPosts(filter: {
authorId: { in: [1, 2] }
}) {
...
}
}
Note: Objects with multiple keys are interpreted with an implicit
AND
between the conditions.
query {
allPosts(filter: {
body: { isNull: false },
createdAt: { greaterThan: "2021-01-01" }
}) {
...
}
}
query {
allPosts(filter: {
or: [
{ authorId: { equalTo: 6 } },
{ createdAt: { greaterThan: "2021-01-01" } }
]
}) {
...
}
}
query {
allPosts(filter: {
not: {
or: [
{ authorId: { equalTo: 6 } },
{ createdAt: { greaterThan: "2021-01-01" } }
]
}
}) {
...
}
}
query {
allPeople(
filter: {
computedColumn: {
equalTo: 17
args: { firstArgument: 1, secondArgument: 2 }
}
}
) {
nodes {
firstName
lastName
}
}
}
The args
are passed to the SQL function that is resposible for creating the computed column:
FUNCTION people_computed_column(person people, first_argument int, second_argument int)
query {
allPeople(filter: {
firstName: { startsWith:"John" }
}) {
nodes {
firstName
lastName
postsByAuthorId(filter: {
createdAt: { greaterThan: "2021-01-01" }
}) {
nodes {
...
}
}
}
}
}
Requires
connectionFilterRelations: true
query {
allPosts(filter: {
personByAuthorId: { createdAt: { greaterThan: "2021-01-01" } }
}) {
...
}
}
A node passes the filter if a related node exists and the filter criteria for the related node are satisfied. (If a related node does not exist, the check fails.)
The *Exists
Boolean field can be used to filter on the existence of a related node:
query {
allPosts(filter: { personByAuthorIdExists: true }) {
nodes {
id
}
}
}
The *Exists
Boolean field is only exposed on nullable relations. For example, if the post.author_id
column is defined as not null
, a related person
always exists, so the personByAuthorIdExists
field is not exposed.
Requires
connectionFilterRelations: true
query {
allPeople(filter: {
accountByAccountId: { status: { equalTo: ACTIVE } }
}) {
...
}
}
A node passes the filter if a related node exists and the filter criteria for the related node are satisfied. (If a related node does not exist, the check fails.)
The *Exists
Boolean field can be used to filter on the existence of a related node:
query {
allPeople(filter: { accountByAccountId: true }) {
nodes {
id
}
}
}
The *Exists
Boolean field is only exposed on nullable relations. For example, if the person.account_id
column is defined as not null
, a related account
always exists, so the accountByAccountIdExists
field is not exposed.
Requires
connectionFilterRelations: true
One-to-many relation fields require the filter criteria to be nested under every
, some
, or none
.
query {
allPeople(
filter: { postsByAuthorId: { some: { status: { equalTo: PUBLISHED } } } }
) {
nodes {
id
}
}
}
The *Exist
Boolean field can be used to filter on the existence of related records:
query {
allPeople(filter: { postsByAuthorIdExist: true }) {
nodes {
id
}
}
}
For additional examples, see the tests.