Skip to content

JSON:API Related Notes

\Drupal\jsonapi\Query\EntityCondition::$allowedOperators = [
  '=', '<>',
  '>', '>=', '<', '<=',
  'STARTS_WITH', 'CONTAINS', 'ENDS_WITH',
  'IN', 'NOT IN',
  'BETWEEN', 'NOT BETWEEN',
  'IS NULL', 'IS NOT NULL',
];

Ref: HTML URL Encoding Reference

Operator Encoded version
= %3D
<> %3C%3E
> %3E
>= %3E%3D
< %3C
<= %3C%3D

filter

/../tr/jsonapi/../node/species?dil=tr AND (title CONTAİNS 'XX' OR açıklama CONTAINS 'XX' OR açıklama CONTAINS 'XX')

Filters

Language Filter

short version

?filter[langcode]=tr

long version

?filter[lang_filter][condition][path]=langcode
&filter[lang_filter][condition][operator]=%3D
&filter[lang_filter][condition][value]=tr

NOT IN (with sorting)

?filter[lang_filter][condition][operator]=NOT%20IN
&filter[lang_filter][condition][path]=drupal_internal__id
&filter[lang_filter][condition][value][1]=und
&filter[lang_filter][condition][path]=drupal_internal__id
&filter[lang_filter][condition][value][2]=zxx
&sort[sort-label][path]=label

Because of the nature of this filter, it is enough to use [path] once.

?filter[lang_filter][condition][operator]=NOT%20IN
&filter[lang_filter][condition][path]=drupal_internal__id
&filter[lang_filter][condition][value][1]=und
&filter[lang_filter][condition][value][2]=zxx
&sort[sort-label][path]=label

IMHO, the second version is more readable. It is also more semantically correct because the path is the same for both values. The first version may give the impression that there are two different paths, which is not the case.

?filter[lang_filter][condition][path]=drupal_internal__id
&filter[lang_filter][condition][operator]=NOT%20IN
&filter[lang_filter][condition][value][1]=und
&filter[lang_filter][condition][value][2]=zxx
&sort[sort-label][path]=label