Every GraphQL search filter can use AND, OR, and NOT operators.
and
, or
, and not
operators.
GraphQL syntax uses infix notation, so: “a and b” is a, and: { b }
, “a or b or
c” is a, or: { b, or: c }
, and “not” is a prefix (not:
).
The following example queries demonstrate the use of and
, or
, and not
operators:
Example: posts that don’t have “GraphQL” in the title
and
operator is implicit for a single filter object, if the fields don’t
overlap. For example, the and
is required because title
is in both filters,
whereas in the query below and
isn’t required.
and
and or
filter both accept a list of filters. Per the GraphQL
specification, non-list filters are coerced into a list. This provides
backwards-compatibility while allowing for more complex filters.
Example: “Query for posts that have GraphQL
in the title but that lack the
GraphQL
tag, or that have Dgraph
in the title but lack the Dgraph
tag”
and
/or
conjunction can be simplified into a
single list.
For example, the following complex query: