From cdeb9183e78b12523cf409abcd1e3f1a882650de Mon Sep 17 00:00:00 2001 From: Valentin Cocaud Date: Thu, 6 Feb 2025 13:45:18 +0100 Subject: [PATCH] changeset --- .changeset/curvy-months-invite.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .changeset/curvy-months-invite.md diff --git a/.changeset/curvy-months-invite.md b/.changeset/curvy-months-invite.md new file mode 100644 index 0000000000..e1c3e2a9cb --- /dev/null +++ b/.changeset/curvy-months-invite.md @@ -0,0 +1,21 @@ +--- +'graphql-yoga': minor +--- + +## New hook `onOperation` + +This new hook is called for each GraphQL operaiton to handle. It allows to replace the +default Yoga operation handler. + +Example: Wrap the GraphQL handling pipeline in an `AsyncLocalStorage` + +```ts +function myPlugin(): Plugin { + const context = new AsyncLocalStorage(); + return { + onOperation({ operationHandler, setOperationHandler }) { + const store = { foo: 'bar' } + setOperationHandler((payload) => context.run(store, operationHandler, payload)) + } +} +``` \ No newline at end of file