-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01a6195
commit cdeb918
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
``` |