

GraphQLize Update (#3) - Logical Operators & Filter by nested objects. | Gra...
source link: https://www.graphqlize.org/blog/graphqlize-update-3/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

GraphQLize Update (#3) - Logical Operators & Filter by nested objects.
Tamizhvendan S
Author, GraphQLizeHello World,
The third iteration of GraphQLize went well as planned and the filters in GraphQLize just got better :).
Let's take a peek at what's new in GraphQLize and what is in the pipeline for the next two weeks.
Logical Operators#
Now we can use logical operators and
, or
and not
in the filters.
AND#
and
also supports list of conditions.
The above query can be rewritten as
OR#
or
is similar to and
in syntax. It accepts both a single condition or a list of conditions.
NOT#
Using the not
operator we can invert the filter condition.
Filter by nested object(s)#
Another major feature that was added during the last iteration is filtering the resulting objects based on the fields of a nested object(s).
One to One#

For example, to get all the cities of a country using the country's name in the above schema, We can query it as
One to Many#
If the nested object has one-to-many
relationship with its parent, the filter condition yield the results if at-least one of the nested object's field(s) satisfy the condition.
For the above schema, we can get a list of countries which has at-least one city that starts with Ab
using the below query.
Many to Many#
A filter based on a nested object with the many-to-many
relationship behaves the same as that of one-to-many
.

For the above schema, to get the actors who are part of at-lease one film which has the word LIFE
in its title.
Let's assume that we have a schema like below

To filter authors who has at-least one course with the rating 5
, we can achieve it using the following query.
If we want to filter only the authors who has got the rating 5
in all their courses, we can achieve it by
We are making use of SQL anti-join here by inverting the whole condition using not
and complementing the inner condition using its reverse (neq
in the place of eq
).
Existence Check#
GraphQLize provides a special filter parameter have
to filter based on the existence of child objects. For example, in the above schema, if we'd like to filter only the authors who have courses, it can be achieved using the following query.
Suppose, if we want to filter authors who don't have courses
, we can make use of the not
in addition to have
in the filter.
The
have
parameter is available only in theone-to-many
andmany-to-many
relationship fields
What's Next?#
The focus of the next iteration of GraphQLize is adding support for SQL aggregate functions.
You can keep track of the progress by
Cheers,
Tamizh
Recommend
-
29
My last piece Challenge your performance intuition with C++ operators was about how the context matters more th...
-
20
GraphQLize Update (#1) - Pagination, Scalar Types, Scala & Kotlin SupportApril 4, 2020 · 4 min readTamizhvendan SAuthor,...
-
17
GraphQLize Update (#2) - Supports Sorting, Filtering & MySQL Boolean TypesApril 20, 2020 · 4 min readTamizhvendan SAutho...
-
31
GraphQLize Update (#4) - Aggregate Functions & Group By.May 20, 2020 · 3 min readTamizhvendan SAuthor, GraphQLize
-
14
Logical assignment operators in JavaScript combine Logical Operators and Assignment Expressions. //...
-
15
How to Read Nested Ternary Operators posted by Craig Gidney on August 6, 2013 Here’s a puzzle that’s hard if you don’t know how...
-
8
Sandor Dargo 9 hours ago2021-05-05T00:00:00+02:00In February and March, most of my posts were about C++ concepts and now I’m am...
-
6
ECMAScript 2021 Language Specification recently reached to a release candidate, introducing many new JavaScript language features. One of the new additions are logical assignment operators...
-
10
-
2
SQL Logical Operators ALL, AND, ANY, BETWEEN, EXISTS, IN, LIKE, NOT, OR, SOME By: Joe Gavin | Updated: 2023-0...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK