0.2.0 • Published 7 years ago
graphql-factory-plugin v0.2.0
graphql-factory-plugin
Base class for GraphQL Factory plugins
Description
All GraphQL Factory plugins should extend this class.
Example
import FactoryPlugin from 'graphql-factory-plugin'
export default class MyPlugin extends FactoryPlugin {
constructor () {
const context = {
foo: 'bar'
}
super('MyPlugin', context)
}
install (definition) {
definition.before(...)
}
}
Constructor
The constructor takes the following arguments
name
- Unique plugin name. Requiredcontext
- Optional context object to assign into the main contextfunctions
- Optional functions hashtypes
- Optional type definitions hashschemas
- Optional schema definitions hash
Install
The install method should be overridden when necessary. An example would be to register
before
, after
, or error
middleware as well as registering dependent plugins.