0.2.0 • Published 7 years ago

graphql-factory-plugin v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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.