Skip to content

feat(codegen): add AbortSignal and per-request headers to NodeHttpAdapter#743

Merged
pyramation merged 1 commit intomainfrom
devin/1772067233-node-http-adapter-enhancements
Feb 26, 2026
Merged

feat(codegen): add AbortSignal and per-request headers to NodeHttpAdapter#743
pyramation merged 1 commit intomainfrom
devin/1772067233-node-http-adapter-enhancements

Conversation

@pyramation
Copy link
Contributor

feat(codegen): add AbortSignal and per-request headers to NodeHttpAdapter

Summary

Adds two capabilities to NodeHttpAdapter in the codegen node-fetch.ts template that were present in the old browserCompatible=false implementation but missing from the current adapter:

  1. AbortSignal support — callers can cancel in-flight node:http requests (important for CLI Ctrl+C and React Query component unmount).
  2. Per-request header overrides — callers can pass one-off headers to a single execute() call without mutating the adapter instance.

Both are exposed via a new optional NodeHttpExecuteOptions parameter on execute(). The base GraphQLAdapter interface is not changed — the extra optional parameter is backward-compatible.

Changes are confined to a single template file (node-fetch.ts) that is copied verbatim into generated output at codegen time.

Review & Testing Checklist for Human

  • Verify execute() signature stays compatible with GraphQLAdapter interface — the third optional param should not break assignability, but confirm TypeScript is happy in a generated project that uses NodeHttpAdapter as a GraphQLAdapter.
  • Verify AbortSignal cleanup — on normal completion, req.on('close') removes the abort listener. On abort, req.destroy() triggers close which also cleans up. Confirm no leak path exists (e.g., if the promise rejects before the request is created).
  • Test with a real codegen run — since this is a template file excluded from TS compilation, the only way to validate types is to run codegen and compile the output. Generate a project with nodeHttpAdapter: true and verify the output compiles and the new options work at runtime.

Notes

  • The template file (node-fetch.ts) is excluded from the codegen package's own tsconfig.json, so package-level tsc will not catch type errors in this file.
  • Caller sites (executor-generator, ORM index) do not yet pass these new options through — they remain available for direct usage of NodeHttpAdapter by consuming applications.
  • ESLint config in the codegen package appears to be broken pre-existing (missing eslint.config.js for ESLint v9); unrelated to this change.

Link to Devin run: https://app.devin.ai/sessions/73d9c02182a240e3857850d776bad754
Requested by: @pyramation

…pter

- Add optional AbortSignal support to makeRequest() for request cancellation
  (early reject if already aborted, destroy request on abort event, clean up listener on close)
- Add NodeHttpExecuteOptions interface with headers and signal fields
- Add optional options parameter to NodeHttpAdapter.execute() for per-request
  header overrides and AbortSignal
- These additions are backward-compatible (all new parameters are optional)
  and extend beyond the base GraphQLAdapter interface
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 00a06fc into main Feb 26, 2026
44 checks passed
@pyramation pyramation deleted the devin/1772067233-node-http-adapter-enhancements branch February 26, 2026 01:01
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.

1 participant