Skip to content

Conversation

@github-actions
Copy link
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@envelop/core@5.3.0

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/apollo-datasources@6.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/apollo-federation@7.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/apollo-server-errors@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/apollo-tracing@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/on-resolve@6.0.0

@envelop/auth0@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/dataloader@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/depth-limit@6.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/disable-introspection@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/execute-subscription-event@7.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/extended-validation@6.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/filter-operation-type@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/fragment-arguments@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/generic-auth@10.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/extended-validation@6.0.0

@envelop/graphql-jit@10.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/graphql-middleware@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/graphql-modules@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/immediate-introspection@6.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/live-query@9.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/newrelic@9.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/on-resolve@6.0.0

@envelop/on-resolve@6.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/opentelemetry@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/on-resolve@6.0.0

@envelop/operation-field-permissions@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/extended-validation@6.0.0

@envelop/parser-cache@9.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/persisted-operations@9.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/preload-assets@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/prometheus@13.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/on-resolve@6.0.0

@envelop/rate-limiter@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/on-resolve@6.0.0

@envelop/resource-limitations@7.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0
    • @envelop/extended-validation@6.0.0

@envelop/response-cache@8.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/response-cache-cloudflare-kv@4.0.0

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@8.0.0

@envelop/response-cache-redis@4.2.4

Patch Changes

  • Updated dependencies []:
    • @envelop/response-cache@8.0.0

@envelop/sentry@14.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/statsd@7.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/validation-cache@9.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@envelop/testing@9.0.0

Patch Changes

  • Updated dependencies
    [3ebaa3b]:
    • @envelop/core@5.3.0

@github-actions github-actions bot force-pushed the changeset-release/main branch from ed39794 to 6e8189c Compare June 20, 2025 13:37
@EmrysMyrddin EmrysMyrddin merged commit 9f0d6ff into main Jun 20, 2025
@EmrysMyrddin EmrysMyrddin deleted the changeset-release/main branch June 20, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant