query message_thread ($firstUserId: Int!, $secondUserId: Int!) {
message_thread(
where: {first_user_id: {_in: [$firstUserId, $secondUserId]},
second_user_id: {_in: [$secondUserId, $firstUserId]}
}
) {
id
first_user_id
second_user_id
}
}
query like this treats two _in conditions with OR top level


@moksahero Fields at the top level are combined with an SQL AND. If you need an OR behavior, you'll need to use _or operator.
For example, query such as this:
query {
tracks(where: {
id: {_in: [1,2]}
album_id: {_in: [1,2]}
}) {
id
album_id
}
}
gets converted into
SELECT
coalesce(json_agg("root"), '[]') AS "root"
FROM
(
SELECT
row_to_json(
(
SELECT
"_1_e"
FROM
(
SELECT
"_0_root.base"."id" AS "id",
"_0_root.base"."album_id" AS "album_id"
) AS "_1_e"
)
) AS "root"
FROM
(
SELECT
*
FROM
"public"."tracks"
WHERE
(
(
("public"."tracks"."id") IN (('1') :: integer, ('2') :: integer)
)
AND (
("public"."tracks"."album_id") IN (('1') :: integer, ('2') :: integer)
)
)
) AS "_0_root.base"
) AS "_2_root"
You can see that the conditions are ANDed.
for record _or operator can be used to the top level to connect all WHERE fields by OR
{
where: {_or: [
{..},
{..}
]}
}
Most helpful comment
for record _or operator can be used to the top level to connect all WHERE fields by OR
{
where: {_or: [
{..},
{..}
]}
}