Skip to content

Releases: graphql-hive/envelop

June 20, 2025

20 Jun 19:03
9f0d6ff
Compare
Choose a tag to compare

@envelop/[email protected]

Minor Changes

  • #2607
    3ebaa3b
    Thanks @EmrysMyrddin! - Added new withState plugin utility
    for easy data sharing between hooks.

    New plugin utility to ease data sharing between hooks

    Sometimes, plugins can grow in complexity and need to share data between its hooks.

    A way to solve this can be to mutate the graphql context, but this context is not always available
    in all hooks in Yoga or Hive Gateway plugins. Moreover, mutating the context gives access to your
    internal data to all other plugins and graphql resolvers, without mentioning performance impact on
    field access on this object.

    The recommended approach to this problem was to use a WeakMap with a stable key (often the
    context or request object). While it works, it's not very convenient for plugin developers,
    and is prone to error with the choice of key.

    The new withState utility solves this DX issue by providing an easy and straightforward API for
    data sharing between hooks.

    import { withState } from '@envelop/core'
    
    type State = { foo: string }
    
    const myPlugin = () =>
      withState<Plugin, State>(() => ({
        onParse({ state }) {
          state.forOperation.foo = 'foo'
        },
        onValidate({ state }) {
          const { foo } = state.forOperation
          console.log('foo', foo)
        }
      }))

    The state payload field will be available in all relevant hooks, making it easy to access shared
    data. It also forces the developer to choose the scope for the data:

    • forOperation for a data scoped to GraphQL operation (Envelop, Yoga and Hive Gateway)
    • forRequest for a data scoped to HTTP request (Yoga and Hive Gateway)
    • forSubgraphExecution for a data scoped to the subgraph execution (Hive Gateway)

    Not all scopes are available in all hooks, the type reflects which scopes are available

    Under the hood, those states are kept in memory using WeakMap, which avoid any memory leaks.

    It is also possible to manually retrieve the state with the getState function:

    const myPlugin = () =>
      withState(getState => ({
        onParse({ context }) {
          // You can provide a payload, which will dictate which scope you have access to.
          // The scope can contain `context`, `request` and `executionRequest` fields.
          const state = getState({ context })
          // Use the state elsewhere.
        }
      }))

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

Read more

March 06, 2025

06 Mar 15:37
e55f53a
Compare
Choose a tag to compare

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

  • Updated dependencies
    [914f9ed,
    [914f9ed](https://...
Read more

March 06, 2025

06 Mar 10:52
7b5db86
Compare
Choose a tag to compare

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

Read more

March 05, 2025

05 Mar 10:53
93e04d7
Compare
Choose a tag to compare

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

  • ...
Read more

March 04, 2025

04 Mar 11:40
6defe10
Compare
Choose a tag to compare

@envelop/[email protected]

Minor Changes

  • #2430
    a107c89
    Thanks @EmrysMyrddin! - ## New Instruments API

    Introducation of a new API allowing to instrument the graphql pipeline.

    This new API differs from already existing Hooks by not having access to intup/output of phases.
    The goal of Instruments is to run allow running code before, after or araound the whole
    process of a phase
    , incuding plugins hooks executions.

    The main use case of this new API is observability (monitoring, tracing, etc...).

    Basic usage

    import { envelop } from '@envelop/core'
    import Sentry from '@sentry/node'
    
    const getEnveloped = envelop({
      plugins: [
        {
          instruments: {
            execute: ({ context }, wrapped) =>
              Sentry.startSpan({ name: 'Graphql Operation' }, async () => {
                try {
                  await wrapped()
                } catch (err) {
                  Sentry.captureException(err)
                }
              })
          }
        }
      ]
    })

    Mutliple instruments plugins

    It is possilbe to have multiple instruments plugins (Prometheus and Sentry for example), they will
    be automatically composed by envelop in the same order than the plugin array (first is outtermost,
    last is inner most).

    import { useOpentelemetry } from '@envelop/opentelemetry'
    import { useSentry } from '@envelop/sentry'
    
    const getEnveloped = envelop({
      plugins: [useSentry(), useOpentelemetry()]
    })
    sequenceDiagram
      Sentry->>Opentelemetry: ;
      Opentelemetry->>Envelop: ;
      Envelop->>Opentelemetry: ;
      Opentelemetry->>Sentry: ;

    Custom instruments ordering

    If the default composition ordering doesn't suite your need, you can mannually compose
    instruments. This allows to have a different execution order of hooks and instruments.

    import { useOpentelemetry } from '@envelop/opentelemetry'
    import { composeInstruments, useSentry } from '@envelop/sentry'
    
    const { instruments: sentryInstruments, ...sentryPlugin } = useSentry()
    const { instruments: otelInstruments, ...otelPlugin } = useOpentelemetry()
    const instruments = composeInstruments([otelInstruments, sentryInstruments])
    
    const getEnveloped = envelop({
      plugins: [{ instruments }, sentryPlugin, otelPlugin]
    })
    sequenceDiagram
      Opentelemetry->>Sentry: ;
      Sentry->>Envelop: ;
      Envelop->>Sentry: ;
      Sentry->>Opentelemetry: ;

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

Read more

February 25, 2025

25 Feb 13:49
adad2da
Compare
Choose a tag to compare

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

Read more

February 20, 2025

20 Feb 12:44
08fff3b
Compare
Choose a tag to compare

@envelop/[email protected]

Patch Changes

February 19, 2025

19 Feb 11:15
0b8fb8d
Compare
Choose a tag to compare

@envelop/[email protected]

Patch Changes

February 19, 2025

19 Feb 00:30
57a6fea
Compare
Choose a tag to compare

@envelop/[email protected]

Minor Changes

  • #2438
    9bd1b20
    Thanks @ardatan! - Add context field to onExecute and
    onSubscribe hooks payloads. This harmonize all the hooks invovled in the handling of a graphql
    operation.

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

@envelop/[email protected]

Patch Changes

Read more

January 27, 2025

27 Jan 19:55
51e5f3e
Compare
Choose a tag to compare

@envelop/[email protected]

Minor Changes

@envelop/[email protected]

Patch Changes