docs(express): document resolver response manipulation - #157
Open
ayushvyas-dev wants to merge 1 commit into
Open
docs(express): document resolver response manipulation#157ayushvyas-dev wants to merge 1 commit into
ayushvyas-dev wants to merge 1 commit into
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR addresses #141 by documenting how to access the Express Response via the request context and demonstrating how to expose it through the GraphQL context so resolvers can manipulate HTTP headers.
Changes:
- Expanded Express adapter documentation to describe
req.context.resand provide a resolver example for setting response headers/cookies. - Added a regression test verifying a resolver can set an HTTP response header through the Express response object.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/use.test.ts | Adds an Express regression test proving a resolver can set an HTTP header via the Express Response. |
| src/use/express.ts | Updates Express adapter docs to explain response exposure through request/GraphQL context and provide example usage. |
Suppressed comments (1)
src/use/express.ts:91
- These lines state that GraphQL resolvers can access the response via
req.context.res, but resolvers don’t receivereq; they receive the GraphQL context value. Reword to indicatereq.context.resis on the handler request, and that you can pass it into resolvers by returning it from thecontextoption.
* The Express response is available to GraphQL resolvers through
* `req.context.res`. This can be used to manipulate the HTTP response,
* for example to set response headers or cookies.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+14
to
+16
| * The `res` property is the Express response object for the current request. | ||
| * It can be used to manipulate the HTTP response from the `context` option | ||
| * or from GraphQL resolvers, for example to set response headers or cookies. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses #141 by documenting how GraphQL resolvers can access and manipulate the Express response through the request context.
Changes
RequestContextdocumentation to explain thatreq.context.resprovides access to the current ExpressResponse.Testing
yarn testyarn check:typeyarn check:lintyarn check:formatgit diff --checkCloses #141