Skip to content

docs(express): document resolver response manipulation - #157

Open
ayushvyas-dev wants to merge 1 commit into
graphql:mainfrom
ayushvyas-dev:fix/express-resolver-response
Open

docs(express): document resolver response manipulation#157
ayushvyas-dev wants to merge 1 commit into
graphql:mainfrom
ayushvyas-dev:fix/express-resolver-response

Conversation

@ayushvyas-dev

Copy link
Copy Markdown

Description

This PR addresses #141 by documenting how GraphQL resolvers can access and manipulate the Express response through the request context.

Changes

  • Updated the Express RequestContext documentation to explain that req.context.res provides access to the current Express Response.
  • Added an example showing how to expose the response through the GraphQL context and manipulate response headers from a resolver.
  • Added a regression test verifying that a GraphQL resolver can set an HTTP response header through the Express response object.

Testing

  • yarn test
  • yarn check:type
  • yarn check:lint
  • yarn check:format
  • git diff --check

Closes #141

Copilot AI lite review requested due to automatic review settings September 1, 2026 15:22
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 1, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ayushvyas-dev / name: ayushvyas-dev (3ae3f73)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.res and 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 receive req; they receive the GraphQL context value. Reword to indicate req.context.res is on the handler request, and that you can pass it into resolvers by returning it from the context option.
 * 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 thread src/use/express.ts
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Express handler receiving HTTP response reference

2 participants