Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • DrupalJsonApiParams

Implements

Index

Properties

qsOptions: object = {}

Init Constructors

Helper Methods

  • addCustomParam(input: ParamBag<any>): void
  • 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']})

    Parameters

    • input: ParamBag<any>

      The parameter object

    Returns void

  • getQueryString(options?: object): string
  • Get query string.

    Parameters

    • Optional options: object

      Options to be passed to qs library during parsing.

    Returns string

Init Methods

  • Initialize with a previously stored query string.

    Parameters

    • input: string

      The Query string to use for initializing.

    • Optional options: object

      Options to be passed to qs library during parsing.

    Returns DrupalJsonApiParams

JSON:API Query Methods

  • Add JSON:API field.

    The name of this method might be miss leading. Use this to explicitely request for specific fields on an entity.

    Parameters

    • type: string

      Resource type

    • fields: string[]

      Array of field names in the given resource type

    Returns DrupalJsonApiParams

  • Add JSON:API group.

    Parameters

    • name: string

      Name of the group

    • conjunction: string = 'OR'

      All groups have conjunctions and a conjunction is either AND or OR.

    • Optional memberOf: string

      Name of the group, this group belongs to

    Returns DrupalJsonApiParams

  • addFilter(path: string, value: null | string | string[], operator?: string, memberOf?: string, key?: string): DrupalJsonApiParams
  • 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

    Read more about filter in Drupal.org Documentation

    Parameters

    • path: string

      A 'path' identifies a field on a resource

    • value: null | string | string[]

      string[] | null` | A 'value' is the thing you compare against. For operators like "IN" which supports multiple parameters, you can supply an array.

    • operator: string = '='

      An 'operator' is a method of comparison

    • Optional memberOf: string

      Name of the group, the filter belongs to

    • Optional key: string

    Returns DrupalJsonApiParams

Other Methods

  • generateKeyName(obj: any, proposedKey: string, enforceKeyName?: boolean): string
  • Parameters

    • obj: any
    • proposedKey: string
    • enforceKeyName: boolean = false

    Returns string

  • getQsOption(): object

Generated using TypeDoc