@envelop/core
6.0.1 · 12 Nov 2026MIT12.6M / weekRepositoryHomepagenpmAtom feed
5.6.1 is the newest release of 5.x.
In short
1 new2 internal
Release note
The section about @envelop/core of a note shared by several packages.
Minor Changes
#2430
a107c89
Thanks @EmrysMyrddin! - ## NewInstrumentsAPIIntroducation 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 ofInstrumentsis 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()]
})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]
})Patch Changes
#2430
a107c89
Thanks @EmrysMyrddin! - dependencies updates:Added dependency
@envelop/instruments@workspace:^↗︎
(todependencies)
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.