Add custom parameter to the query.
E.g. usage
apiParams
// To add `foo=bar` to the query.
.addCustomParam({foo: 'bar'})
// To add `foo[bar]=baz` to the query.
.addCustomParam({ foo: {bar: 'baz'}})
// To add `bar[0]=a&bar[1]=b&bar[2]=c` to the query.
.addCustomParam({ bar: ['a', 'b', 'c']})
The parameter object
Get query object.
Get query string.
Options to be passed to qs
library during parsing.
Clear all parameters added so far.
Clone a given DrupalJsonApiParam object.
Initialize with a previously stored query object.
Initialize with a previously stored query string.
The Query string to use for initializing.
Options to be passed to qs
library during parsing.
Initialize with a previously stored query/object/query string.
Add JSON:API field.
The name of this method might be miss leading. Use this to explicitely request for specific fields on an entity.
Resource type
Array of field names in the given resource type
Add JSON:API sort.
Used to return the list of items in specific order.
A 'path' identifies a field on a resource
Sort direction ASC
or DESC
Add JSON:API page limit.
Use to restrict max amount of items returned in the listing. Using this for pagination is tricky, and make sure you read the following document on Drupal.org to implement it correctly.
Number of items to limit to
Add JSON:API page offset.
Use to skip some items from the start of the listing. Using this for pagination is tricky, and make sure you read the following document on Drupal.org to implement it correctly.
Number of items to skip from the begining.
Add JSON:API include.
Used to add referenced resources inside same request. Thereby preventing additional api calls.
Array of field names
Add JSON:API group.
Name of the group
All groups have conjunctions and a conjunction is either AND
or OR
.
Name of the group, this group belongs to
Add JSON:API filter.
Following values can be used for the operator. If none is provided, it assumes "=
" by default.
'=', '<>',
'>', '>=', '<', '<=',
'STARTS_WITH', 'CONTAINS', 'ENDS_WITH',
'IN', 'NOT IN',
'BETWEEN', 'NOT BETWEEN',
'IS NULL', 'IS NOT NULL'
NOTE: Make sure you match the value supplied based on the operators used as per the table below
Value Type | Operator | Comment |
---|---|---|
string |
= , <> , > , >= , < , <= , STARTS_WITH , CONTAINS , ENDS_WITH |
|
string[] |
IN , NOT IN |
|
string[] size 2 |
BETWEEN , NOT BETWEEN |
The first item is used for min (start of the range), and the second item is used for max (end of the range). |
null |
IS NULL , IS NOT NULL |
Must use null |
A 'path' identifies a field on a resource
string[] | null` | A 'value' is the thing you compare against. For operators like "IN" which supports multiple parameters, you can supply an array.
An 'operator' is a method of comparison
Name of the group, the filter belongs to
Set options that is passed to qs when parsing/serializing.
Get options that is passed to qs when parsing/serializing.
Generated using TypeDoc
Optionaly initialize with a previously stored query/object/query string.