API Documentation

druxt

druxt

Modules

druxt

The DruxtStore Vuex module.

Provides a Vuex state object, mutations and actions for interacting with the DruxtClient.

Typedefs

addCollectionContext : object

Parameters for the addCollection mutation.

addResourceContext : object

Parameters for the addResource mutation.

getCollectionContext : object

Parameters for the getCollection action.

getResourceContext : object

Parameters for the getResource action.

DruxtClientQuery : string | object

A correctly formatted JSON:API query string or object.

druxt

The DruxtStore Vuex module.

Provides a Vuex state object, mutations and actions for interacting with the DruxtClient.


getCollection(context) ⇒ Array.<object>

Get collection of resources.
Vuex Action => Mutates state propertyundefined

Kind: action method of druxt
Returns: Array.<object> - Array of Drupal JSON:API resource data.

ParamType
contextgetCollectionContext

Example

// Load all currently published Articles.
const resources = await this.$store.dispatch('druxt/getCollection', {
  type: 'node--article',
  query: new DrupalJsonApiParams().addFilter('status', '1'),
})

getResource(context) ⇒ object

Get JSON:API Resource.

  • Executes query against Drupal JSON:API.
  • Caches result in the Vuex store.
  • Returns cached result from Vuex store when available.
    Vuex Action => Mutates state propertyresources

Kind: action method of druxt
Returns: object - The Drupal JSON:API resource.

ParamType
contextgetResourceContext

Example

const resource = await this.$store.dispatch('druxt/getResource', { type: 'node--article', id })

state : object

Vuex State object.

Read only: true
Properties

NameTypeDescription
collectionsDruxtClientCollectionsJSON:API resource collections store.
resourcesobjectJSON:API resources store.

addCollection

Adds a JSON:API collection to the Vuex state object.

Kind: mutation method of druxt

ParamType
contextaddCollectionContext

Example

this.$store.commit('druxt/addCollection', { collection, type, hash })

addResource

Adds a JSON:API resource to the Vuex state object.

Kind: mutation method of druxt

ParamType
contextaddResourceContext

Example

this.$store.commit('druxt/addResource', { resource })

addCollectionContext : object

Parameters for the addCollection mutation.

Kind: global typedef

ParamTypeDescription
collectionobjectA collection of JSON:API resources.
typestringThe JSON:API collection resource type.
hashstringAn md5 hash of the query string.

Example

{
  collection: {
    jsonapi: {},
    data: [{}],
    links: {}
  },
  type: 'node--page',
  hash: '_default'
}

addResourceContext : object

Parameters for the addResource mutation.

Kind: global typedef

ParamTypeDescription
resourceobjectThe JSON:API resource.

Example

{
  resource: {
    jsonapi: {},
    data: {},
    links: {}
  },
}

getCollectionContext : object

Parameters for the getCollection action.

Kind: global typedef

ParamTypeDescription
typestringThe JSON:API collection resource type.
[query]DruxtClientQueryA correctly formatted JSON:API query string or object.

Example

{
  type: 'node--page',
  query: new DrupalJsonApiParams().addFilter('status', '1')
}

getResourceContext : object

Parameters for the getResource action.

Kind: global typedef

ParamTypeDescription
typestringThe JSON:API Resource type.
idstringThe Drupal resource UUID.
[query]DruxtClientQueryA correctly formatted JSON:API query string or object.

Example

{
  type: 'node--page',
  id: 'd8dfd355-7f2f-4fc3-a149-288e4e293bdd'
}

DruxtClientQuery : string | object

A correctly formatted JSON:API query string or object.

Kind: global typedef
See: https://www.npmjs.com/package/drupal-jsonapi-params
Example

page[limit]=5&page[offset]=5

Example

new DrupalJsonApiParams().addPageLimit(5)