Packages

@envelop/core

6.0.1 · 12 Nov 2026MIT12.6M / weekRepositoryHomepagenpmAtom feed

Your version

2.0.0

major2 Feb 2022Where it was published

2.6.0 is the newest release of 2.x.

In short

1 breaking2 new1 internal

  • Breaking

    Move onResolverCalled from within OnExecuteHookResult and OnSubscribeHookResult to the Plugin type.

Release note

The section about @envelop/core of a note shared by several packages.

Major Changes

  • Breaking

    Move onResolverCalled from within OnExecuteHookResult and OnSubscribeHookResult to
    the Plugin type.

    import type { Plugin } from "@envelop/core";
    
    const plugin: Plugin = {
      onExecute() {
    -    return {
    -      onResolverCalled() {}
    -    }
    -  }
    +  },
    +  onResolverCalled() {},
    }

    We highly recommend avoiding to use any plugins that use onResolverCalled within your production
    environment as it has severe impact on the performance of the individual resolver functions within
    your schema.

    The schema resolver functions are now ONLY wrapped if any plugin in your envelop setup uses the
    onResolverCalled hook.

    If you need any shared state between onExecute and onResolverCalled you can share it by
    extending the context object.

    import type { Plugin } from '@envelop/core'
    
    const sharedStateSymbol = Symbol('sharedState')
    
    const plugin: Plugin = {
      onExecute({ extendContext }) {
        extendContext({ [sharedStateSymbol]: { value: 1 } })
      },
      onResolverCalled({ context }) {
        const sharedState = context[sharedStateSymbol]
        // logs 1
        console.log(sharedState.value)
      }
    }

Minor Changes

  • Add new option breakContextBuilding to OnContextBuildingEventPayload.

    This allows short-circuiting the context building phase. Please use this with care as careless
    usage of it can result in severe errors during the execution phase, as the context might not
    include all the fields your schema resolvers need.

  • Add new plugin useImmediateIntrospection for speeding up introspection only operations
    by skipping context building.

    import { envelop, useImmediateIntrospection } from '@envelop/core'
    import { schema } from './schema'
    
    const getEnveloped = envelop({
      plugins: [
        useSchema(schema),
        useImmediateIntrospection()
        // additional plugins
      ]
    })

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.