npm.io
0.2.0 • Published 8 years ago

graphql-factory-plugin

Licence
MIT
Version
0.2.0
Deps
0
Vulns
0
Weekly
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. Required
  • [context] - Optional context object to assign into the main context
  • [functions] - Optional functions hash
  • [types] - Optional type definitions hash
  • [schemas] - 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.