GQLBase

GQLBase

new GQLBase()

All GraphQL Type objects used in this system are assumed to have extended
from this class. An instance of this class can be used to wrap an existing
structure if you have one.

Source:

Classes

⎆⠀constructor

Methods

(static) ⌾⠀IDLFilePath(path, extensionopt)

Creates an appropriate Symbol crafted with the right data for use by
the IDLFileHandler class below.

Source:
See:
  • GQLBase#SCHEMA
Parameters:
Name Type Attributes Default Description
path string

a path to the IDL containing file

extension string <optional>
'.graphql'

an extension, including the
prefixed period, that will be added to the supplied path should it not
already exist.

Returns:

Symbol

(static) ⌾⠀MUTATORS(requestData) → {Promise}

This method should return a promise that resolves to an object of
functions matching the names of the mutation operations. These are to be
injected into the root object when used by GQLExpressMiddleware.

Deprecated:
  • Place all resolvers in RESOLVERS()
Source:
Parameters:
Name Type Description
requestData Object

typically an object containing three
properties; {req, res, gql}

Returns:
Type:
Promise

a promise that resolves to an object; see above for more
information.

(static) ⌾⠀setupModel(instance)

The internal data model has some custom EventEmitter code wrapped
it here. When the data model is set via setModel or by accessing it
via instance[MODEL_KEY], an event EVENT_MODEL_SET is emitted. Any
listener listening for this event receives an object with two keys

{
  model: The actual model being set; changes are persisted
  instance: The GQLBase instance the model is associated with
}

Subsequently, the events EVENT_MODEL_PROP_CHANGE and
EVENT_MODEL_PROP_DELETE can be listened to if your version of node
supports Proxy objects. They allow you to be notified whenever your
model has a property changed or deleted, respectively.

The callback for change receives an object with four properties

{
  model: The model object the value is being changed on
  old: The old value being replaced; undefined if it is the first time
  key: The property key for the value being changed
  value: The new value being set
}

The callback for delete receives an object with four properties

{
  model: The model object the value is deleted from
  key: The property key for the deleted value
  deleted: The deleted value
}
Source:
Parameters:
Name Type Description
instance GQLBase

typically this as passed in from a call in
the constructor

⌾⠀getModel(value)

Getter for the internally stored model data. The contents of this
object are abstracted away behind a Symbol key to prevent collision
between the underlying model and any GraphQL Object Definition properties.

Since:
  • 2.5
Source:
Parameters:
Name Type Description
value Object

any object you wish to use as a data store

⬆︎⠀requestData(value)

A setter that assigns a value to the inner request data object. When
used with GQLExpressMiddleware, this is an object matching {req, res, gql}.

Source:
Parameters:
Name Type Description
value Object

an object, usually matching { req, res, gql }