Skip to content

Commit 313e4e1

Browse files
feobabyrikinsk
authored andcommitted
docs: updates doc for _eq, _ne operators to include a caveat for null values
### Description This PR adds an info. on the `eq` and `ne` operators to include a caveat for null values. ### Changelog - [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label. ### Affected components - [x] Docs ### Related Issues hasura#2167 ### Affected pages https://deploy-preview-352--hasura-docs-mono.netlify.app/graphql/core/queries/query-filters.html hasura/graphql-engine-mono#352 Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com> GitOrigin-RevId: 2d707d6
1 parent 20f7a6e commit 313e4e1

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎docs/graphql/core/databases/postgres/queries/query-filters.rst‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,56 @@ Fetch a list of articles that were published on a certain date (``published_on``
201201
}
202202
}
203203

204+
.. admonition:: Caveat for "null" values
205+
206+
By design, the ``_eq`` or ``_neq`` operators will not return rows with ``null`` values.
207+
208+
To also return rows with ``null`` values, the ``_is_null`` operator needs to be used
209+
along with these joined by the ``_or`` operator.
210+
211+
For example, to fetch a list of articles where the ``is_published`` column is either ``false`` or ``null``:
212+
213+
.. graphiql::
214+
:view_only:
215+
:query:
216+
query {
217+
articles (
218+
where: {
219+
_or: [
220+
{is_published: {_eq: false}},
221+
{is_published: {_is_null: true}}
222+
]
223+
}
224+
)
225+
{
226+
id
227+
title
228+
is_published
229+
}
230+
}
231+
:response:
232+
{
233+
"data": {
234+
"articles": [
235+
{
236+
"id": 1,
237+
"title": "Robben Island",
238+
"is_published": false
239+
},
240+
{
241+
"id": 2,
242+
"title": "The Life of Matthias",
243+
"is_published": false
244+
},
245+
{
246+
"id": 3,
247+
"title": "All about Hasura",
248+
"is_published": null
249+
},
250+
]
251+
}
252+
}
253+
204254
Greater than or less than operators (_gt, _lt, _gte, _lte)
205255
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
206256

0 commit comments

Comments
 (0)