useExtendContext

Easily extends the context with custom fields.

Weekly downloads
5.5M
Version
5.6.1
License
MIT
Updated
Sep 16, 2026

coreutilities

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 ...
  ]
})