useExtendContext

useExtendContext

Package nameWeekly DownloadsVersionLicenseUpdated
@envelop/core (opens in a new tab)DownloadsVersionLicenseMay 23rd, 2023

useExtendContext

Easily extends the context with custom fields.

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine, useExtendContext } from '@envelop/core'
 
const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    useExtendContext(async contextSoFar => {
      return {
        myCustomField: {
          /* ... */
        }
      }
    })
    // ... other plugins ...
  ]
})