-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(onParams-handler) * Move error handling inside * Format * Unit tests for params handler * Make linter happy * Update packages/graphql-yoga/src/server.ts
- Loading branch information
Showing
4 changed files
with
150 additions
and
66 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,20 @@ | ||
--- | ||
'graphql-yoga': minor | ||
--- | ||
|
||
Now it is possible to replace or wrap the logic how `GraphQLParams` handled; | ||
|
||
By default Yoga calls Envelop to handle the parameters, but now you can replace it with your own logic. | ||
|
||
Example: Wrap the GraphQL handling pipeline in an `AsyncLocalStorage` | ||
|
||
```ts | ||
function myPlugin(): Plugin { | ||
const context = new AsyncLocalStorage(); | ||
return { | ||
onParams({ paramsHandler, setParamsHandler }) { | ||
const store = { foo: 'bar' } | ||
setParamsHandler(payload => context.run(store, paramsHandler, payload)) | ||
} | ||
} | ||
``` |
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
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
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