A hook to interact with the Hermes API.

Parameters:
NameTypeDescription
propsobject

The props for the hook.

Properties
NameTypeDescription
actionstring

The fallback action to use if queryAction or mutationAction is not provided.

customMutationTypeMapobject

A map of custom mutation types to mutation string builder functions.

endpointstring

The Hermes AJAX endpoint.

mutationActionstring

The mutation action to use.

mutationKeystring

The key in the request body for mutations.

mutationSecuritystring

The security nonce for mutations.

queryActionstring

The query action to use.

queryKeystring

The key in the request body for queries.

querySecuritystring

The security nonce for queries.

securitystring

The security nonce to use if querySecurity or mutationSecurity is not provided.

Since
  • 4.0.5
Returns:

The Hermes state and actions.

Type: 
object

Methods

(async, inner) mutation(args) → {Promise}

Performs mutation on the Hermes API.

Parameters:
NameTypeDescription
argsobject

Args for the mutation.

Properties
NameTypeDescription
mutationObjstring | object

The mutation object.

typestring

The mutation type, one of the base types of insert, update, delete, connect, or disconnect, or a custom mutation type.

headersobject

The headers for the mutation.

bodyobject

The body for the mutation.

optionsobject

The options for the mutation.

Since
  • 4.0.5
Returns:

The mutation promise.

Type: 
Promise

(async, inner) query(args) → {Promise}

Performs query on the Hermes API.

Parameters:
NameTypeDescription
argsobject

Args for the query.

Properties
NameTypeDescription
queryObjstring | object

The query object.

headersobject

The headers for the query.

bodyobject

The body for the query.

optionsobject

The options for the query.

Since
  • 4.0.5
Returns:

The query promise.

Type: 
Promise