- #1986
68e7a2a5
Thanks @EmrysMyrddin! - Breaking Change: Support of Node 16 is dropped.
-
#1939
f7ef03c0
Thanks @EmrysMyrddin! - TheaddPlugin
function now insert the plugin in place in the plugin list, leading to a more predictable execution order.Breaking Change: This change alter the execution order of plugins. This can break some plugins that was relying on the fact the
addPlugin
allowed to push a plugin to the end of the plugin list.If it is the case, the best fix is to reorder the plugin list and ensure the plugin is in the right position, after all its dependencies.
- Updated dependencies
[
68e7a2a5
]:- @envelop/types@5.0.0
- #1911
dee6b8d2
Thanks @EmrysMyrddin! - The context is now referentialy stable. It means the context passed to all hooks and to all resolver is guaranted to always be the same object instance. This unique object instance will be mutated as needed to extend the context.
- #1944
db20864a
Thanks @EmrysMyrddin! - Fixed plugin duplication when nesting envelop extensions
- Updated dependencies
[
834e1e39
]:- @envelop/types@4.0.1
- #1728
a36925c7
Thanks @ardatan! - - Memoize parsed document string result and use it wherever possible, and exportgetDocumentString
function to allow users to use it as well.- Use
WeakMap
s withDocumentNode
wherever possible instead of using LRU Cache with strings. It is more optimal if a parser caching is used
- Use
- Updated dependencies
[
332f1f22
]:- @envelop/types@4.0.0
-
#1725
c1eb2c09
Thanks @n1ru4l! - dependencies updates:- Updated dependency
tslib@^2.5.0
↗︎ (from2.5.0
, independencies
)
- Updated dependency
-
Updated dependencies [
c1eb2c09
]:- @envelop/types@3.0.2
-
#1706
270249cf
Thanks @renovate! - dependencies updates:- Updated dependency
tslib@2.5.0
↗︎ (from2.4.0
, independencies
)
- Updated dependency
- Updated dependencies
[
e2ff77ed
]:- @envelop/types@3.0.1
- #1560
22f5ccfb
Thanks @enisdenjo! - Plugins with context generic for correct inheritance
-
#1487
dc1e24b5
Thanks @saihaj! - RemoveisIntrospectionQuery
utility -
#1487
dc1e24b5
Thanks @saihaj! - Remove async schema loading plugin. This was a mistake from beginning as we cannot asynchronouslyvalidate
andparse
since with GraphQL.js are synchronous in nature. -
#1487
dc1e24b5
Thanks @saihaj! - RemoveonResolverCalled
We decided to drop onResolverCalled hook and instead provide a new plugin that will let you hook into this phase.
import { parse, validate, execute, subscribe } from 'graphql' import { envelop, Plugin, useEngine } from '@envelop/core' + import { useOnResolve } from '@envelop/on-resolve' import { onResolverCalled } from './my-resolver' function useResolve(): Plugin { return { - onResolverCalled: onResolverCalled, + onPluginInit: ({ addPlugin }) => { + addPlugin(useOnResolve(onResolverCalled)) + }, } } const getEnveloped = envelop({ plugins: [ useEngine({ parse, validate, execute, subscribe }), // ... other plugins ... useResolve(), ], });
-
#1487
dc1e24b5
Thanks @saihaj! - DropuseTiming
pluginThis plugin was dependent on tracing the schema. As we no longer support wrap the schema out of the box we decided to drop this plugin.
-
#1487
dc1e24b5
Thanks @saihaj! - RemoveisIntrospectionDocument
utility -
#1487
dc1e24b5
Thanks @saihaj! - Drop Node v12 supportNode.js v12 is no longer supported by the Node.js team. https://github.com/nodejs/Release/#end-of-life-releases
-
#1487
dc1e24b5
Thanks @saihaj! - DropEnvelopError
classTo keep the core agnostic from a specific implementation we no longer provide the
EnvelopError
class. -
#1487
dc1e24b5
Thanks @saihaj! - RemoveuseAsyncSchema
pluginThis was a mistake from beginning as we cannot asynchronously validate and parse since with graphql these functions are synchronous in nature.
-
#1487
dc1e24b5
Thanks @saihaj! - Removegraphql
as a peer dependencyWe have built the new
envelop
to be engine agnostic.graphql-js
is no longer a peer dependency. Now you can use any spec compliant GraphQL engine withenvelop
and get the benefit of building a plugin system. We have introduced a new plugin that can be used to customize the GraphQL Engine.- import { envelop } from '@envelop/core' + import { envelop, useEngine } from '@envelop/core' + import { parse, validate, execute, subscribe } from 'graphql'; - const getEnveloped = envelop([ ... ]) + const getEnveloped = envelop({ plugins: [useEngine({ parse, validate, execute, subscribe })] })
Checkout the migration guide for more details.
-
#1487
dc1e24b5
Thanks @saihaj! - RenameuseLazyLoadedSchema
touseSchemaByContext
since the original name was vert misleading. -
#1487
dc1e24b5
Thanks @saihaj! - RemoveenableIf
utility in favor of more type safe way to conditionally enable plugins. It wasn't a great experience to have a utilityWe can easily replace usage like this:
- import { envelop, useMaskedErrors, enableIf } from '@envelop/core' + import { envelop, useMaskedErrors } from '@envelop/core' import { parse, validate, execute, subscribe } from 'graphql' const isProd = process.env.NODE_ENV === 'production' const getEnveloped = envelop({ parse, validate, execute, subscribe, plugins: [ // This plugin is enabled only in production - enableIf(isProd, useMaskedErrors()) + isProd && useMaskedErrors() ] })
-
#1487
dc1e24b5
Thanks @saihaj! - RemovehandleValidationErrors
andhandleParseErrors
options fromuseMaskedErrors
.ONLY masking validation errors OR ONLY disabling introspection errors does not make sense, as both can be abused for reverse-engineering the GraphQL schema (see https://github.com/nikitastupin/clairvoyance for reverse-engineering the schema based on validation error suggestions). #1482 (comment)
Rename
formatError
function option tomaskError
-
#1487
dc1e24b5
Thanks @saihaj! - Removed orchestrator tracingGraphQLSchema
was wrapped to provide resolvers/fields tracing from the schema. Issue with this approach was it was very specific to the underlying engine's implementation. With the new version we no longer want to depend to a specific implementation. Now users can wrap their schemas and add tracing themselves.
- #1487
dc1e24b5
Thanks @saihaj! - respond to context, parse and validate errors inuseErrorHandler
plugin
-
#1499
1f7af02b
Thanks @viniciuspalma! - Adding tslib to package dependenciesProjects that currently are using yarn Berry with PnP or any strict dependency resolver, that requires that all dependencies are specified on package.json otherwise it would endue in an error if not treated correct
Since https://www.typescriptlang.org/tsconfig#importHelpers is currently being used, tslib should be exported as a dependency to external runners get the proper import.
Change on each package:
// package.json { "dependencies": { "tslib": "^2.4.0" } }
-
#1496
ae7bc9a3
Thanks @ardatan! - Fix isIntrospectionDocument and isIntrospectionOperation for fragment tricks -
Updated dependencies [
1f7af02b
]:- @envelop/types@2.4.0
- #1471
5a5f5c04
Thanks @n1ru4l! - Ensure error thrown from the context factory is wrapped within a GraphQLError for proper formatting. Previously this caused an unexpected error to be swallowed completly when error masking is enabled.
- 071f946: Fix CommonJS TypeScript resolution with
moduleResolution
node16
ornodenext
- Updated dependencies [071f946]
- @envelop/types@2.3.1
- 787d28a2: Use the custom error formatter for the errors thrown when building the context and the subscription
- 8bb2738: Support TypeScript module resolution.
- Updated dependencies [8bb2738]
- @envelop/types@2.3.0
- fbf6155: update package.json repository links to point to the new home
- Updated dependencies [fbf6155]
- @envelop/types@2.2.1
- 07d029b: use the correct
GraphQLErrorExtensions
interface for theextensions
constructor option onEnvelopError
.
- d5c2c9a: fix immediate introspection for subscription and mutation
-
af23408: Pass context to registerContextErrorHandler
export const useMyHook = (): Plugin => { return { onPluginInit(context) { context.registerContextErrorHandler(({ context }) => { console.error( 'Error occurred during context creation but at least I have the context so far', context ) }) } } }
- Updated dependencies [af23408]
- @envelop/types@2.2.0
-
d5115b4: allow masking validation and parse errors with
useMaskedErrors
.useMaskedErrors({ handleParseErrors: true, handleValidateErrors: true })
This option is disabled by default as validation and parse errors are expected errors that help the API consumer instead of leaking secret information.
If you want to avoid leaking schema suggestions, we recommend using persisted operations.
-
d5115b4: add
setResult
toAfterValidateEventPayload
for altering the validation errors.
- ada7fb0: correctly identify introspection only operations in
useImmediateIntrospection
- Updated dependencies [d5115b4]
- @envelop/types@2.1.0
- 78b3db2: Add
setResultAndStopExecution
to theonSubscribe
context.
- f5eb436: always invoke
onExecutDone
hooks
-
aac65ef: Move
onResolverCalled
from withinOnExecuteHookResult
andOnSubscribeHookResult
to thePlugin
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
andonResolverCalled
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) } }
-
4106e08: Add new option
breakContextBuilding
toOnContextBuildingEventPayload
.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.
-
4106e08: 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 ] })
- Updated dependencies [4106e08]
- Updated dependencies [aac65ef]
- @envelop/types@2.0.0
- 3dfddb5: Bump graphql-tools/utils to v8.6.1 to address a bug in getArgumentsValues
-
d9cfb7c: Support including the original error stack for masked errors within the error extensions via the
isDev
option and thedefaultErrorFormatter
.useMaskedErrors({ isDev: true })
On Node.js environments the
isDev
default value istrue
ifglobalThis.process.env["NODE_ENV"]
is equal to"development"
. Otherwise, the default value is ALWAYSfalse
.
The
FormatErrorHandler
now has a third argumentisDev
which is forwarded from the configuration and can be used for customizing the formatter behavior in development mode.
-
8e365c2: fix potential memory leak when using
onEnd
andonNext
stream handlers for hooking intosubscribe
andexecute
.This has been caused by AsyncGenerators being blocked until the next value is published. Now disposed result streams (AsyncIterables) will properly cleanup the underlying stream source.
-
fd14339: feat(usePayloadFormatter): add second argument with execution arguments
-
128c5d3: Fix context type inference with enableIf helper
- d1a0e4e: Allow userland code to specify type of currentContext in ContextFactoryFn
- d30ef6a: fix issue that caused calculating negative tracing durations
-
521ecb8: Prefer
globalThis.performance.now
for tracing if available. Fallback toDate.now
.Using tracing no longer raises an error on browser, deno and cloudflare worker environments.
- f272b28: useTiming: Fix a typo in onSubscriptionMeasurement
-
b1a0331: Properly list
@envelop/core
as apeerDependency
in plugins.This resolves issues where the bundled envelop plugins published to npm had logic inlined from the
@envelop/core
package, causinginstanceof
check ofEnvelopError
to fail. -
Updated dependencies [b1a0331]
- @envelop/types@1.5.1
- 090cae4: GraphQL v16 support
- Updated dependencies [090cae4]
- @envelop/types@1.5.0
- 3458917: Allow functions returning a plugin in
enableIf
and lazy load plugin by avoiding running the init flow of plugin if value is false. - 04120de: add support for GraphQL.js 16
- Updated dependencies [04120de]
- @envelop/types@1.4.0
- 365a982: Allow async OnExecuteDone hook
- Updated dependencies [365a982]
- @envelop/types@1.3.0
- d65e35d: add enableIf utility to enable plugins conditionally
- 26475c9: useErrorHandler: Pass in the execution arguments to the error handler callbacks.
- Updated dependencies [d65e35d]
- Updated dependencies [26475c9]
- @envelop/types@1.2.0
- eb0a4bd: Adds a custom message option used when masking errors
-
7704fc3: Add API for registering a context creation error handler.
export const useMyHook = (): Plugin => { return { onPluginInit(context) { context.registerContextErrorHandler(({ error, setError }) => { console.error('Error occurred during context creation.', error) setError(new Error('Something went wrong :(')) }) } } }
-
7704fc3:
useMaskedErrors
now masks errors thrown during context creation (callingcontextFactory
).It might be possible that you need to load some data during context creation from a remote source that could be unavailable and thus yield in an error being thrown.
useMaskedErrors
now handles such scenarios and prevents leaking such information to clients.✅ context error will be masked
const getEnveloped = envelop({ plugins: [ useExtendContext(() => { throw new Error('Oooooops.') }), useMaskedErrors() ] })
-
7704fc3: useMaskedErrors now also handles errors that are occurring during subscriptions.
- Updated dependencies [7704fc3]
- @envelop/types@1.1.0
-
35c85a7: ensure legacy graphql execute parameters are passed properly.
// deprecated (removed in GraphQL.js 16) execute(schema, ...args) // how it should be done execute({ schema, ...args })
This fixes an edge-case with graphql frameworks that call execute with the old and deprecated signature.
Thus, Envelop allows developers using server frameworks that hard-core the legacy v15 call signature to immediately use v16 without waiting for framework developers to adjusting it or fork/patch it.
- 452af8f: Update dependencies of graphql-tools to latest
- 94db02d: Added new helper
handleStreamOrSingleExecutionResult
- 94db02d: Update usage of plugins to use the correct
isAsyncIterable
and new helperhandleStreamOrSingleExecutionResult
- Updated dependencies [94db02d]
- Updated dependencies [94db02d]
- @envelop/types@1.0.2
- c24a8fd: re-use graphql "execute" & "subscribe" types
- f45c0bf: Include README and documentation as part of the package
- 8021229: fix ESM graphql import
- adca399: add jsdoc comments for hook types
- Updated dependencies [c24a8fd]
- Updated dependencies [adca399]
- @envelop/types@1.0.1
- 40bc444: v1 major release for envelop packages
- dbb241d: allow hooking into published subscribe values
- Updated dependencies [dbb241d]
- Updated dependencies [40bc444]
- @envelop/types@1.0.0
- bcbaccb: Fix issues with incorrect types generated in d.ts
- Updated dependencies [a7321e1]
- @envelop/types@0.4.2
- 932f6a8: Better type-safety for hooks
- Updated dependencies [932f6a8]
- @envelop/types@0.4.1
- 50dffaa: Added new hook for onEnveloped
- cca1e39: Added built-in plugin: useAsyncSchema
- 778c207: Better type safety for OnEnveloped hook
- Updated dependencies [50dffaa]
- Updated dependencies [778c207]
- @envelop/types@0.4.0
- d82e2d0: Added utils: isOperationDefinition, isIntrospectionOperation, isIntrospectionDocument, isIntrospectionOperationString
- 2113527: Extend Envelop plugin API with the ability to access and replace resolver function
- d82e2d0: Added config flag
skipIntrospection
for useLogger plugin
- 28ad742: Cleanup for some traces related to the tracedOrchestrator
- d82e2d0: useTiming: Allow to specify skipIntrospection configuration
- 28ad742: Improve TypeScript types
- 28ad742: Improve runtime performance by reducing calls to prepareSchema
- Updated dependencies [28ad742]
- Updated dependencies [2113527]
- @envelop/types@0.3.0
- 7f4901d: Fix issues with contextFactory and missing context coming from GraphQL pipeline orchestrator
- Updated dependencies [7f4901d]
- @envelop/types@0.2.1
- a5bee94: * Allow access to context in all phases
- Improve usage of
getEnveloped
function and allow to pass initial context there
- Improve usage of
- eb6f53b: ESM Support for all plugins and envelop core
- Updated dependencies [a5bee94]
- Updated dependencies [eb6f53b]
- @envelop/types@0.2.0
- fd76b26: add missing useEnvelop plugin export
- 8fa4ae2: Add useMaskedErrors plugin.
- d4c8f90: Allow plugins to manage and load other plugins
- d4c8f90: Improve execution times by simplifying some parts of
envelop
code - d4c8f90: Remove
extends
and replaces withuseEnvelop
plugin
- d4c8f90: useTiming: improve plugin creation based on config
- d4c8f90: Introduce TS strict mode
- ced704e: Allow plugins to stop execution and return errors
- Updated dependencies [ced704e]
- @envelop/types@0.1.4
- 5fc65a4: Improve type safety for plugins context
- Updated dependencies [5fc65a4]
- @envelop/types@0.1.3
- f5177eb: Added
setResult
to the result of onResolverCalled - Updated dependencies [f5177eb]
- @envelop/types@0.1.2
- 925a1ea: Extend
onSchemaChange
and allow to override schema. Make sure to avoid infinite loops. - 3b92779: Fix missing exports for built-in plugins
- Updated dependencies [925a1ea]
- @envelop/types@0.1.1
- 2fba0b4: Initial version bump
- Updated dependencies [2fba0b4]
- @envelop/types@0.1.0
- b1333b0: Initial packages release
- Updated dependencies [b1333b0]
- @envelop/types@0.0.2
- c499ae8: First bump as envelop
- 2cfc726: Fixes
- Updated dependencies [c499ae8]
- Updated dependencies [2cfc726]
- @envelop/types@0.0.1