Skip to content

Add optional operationTypeHeader to Apollo client options#163

Merged
finnhodgkin merged 4 commits into
OxfordAbstracts:mainfrom
purefunctor:justin/operation-type-header
Jun 4, 2026
Merged

Add optional operationTypeHeader to Apollo client options#163
finnhodgkin merged 4 commits into
OxfordAbstracts:mainfrom
purefunctor:justin/operation-type-header

Conversation

@purefunctor
Copy link
Copy Markdown
Member

Summary

Adds an opt-in operationTypeHeader :: Maybe String option to the Apollo base clients. When set, HTTP requests carry the GraphQL operation type (query or mutation) as the value of the given header, so infrastructure (e.g. a load balancer) can route queries to a read replica.

  • New createClient' / createSubscriptionClient' constructors taking ApolloClientOptions' / ApolloSubClientOptions' with the extra field.
  • Existing createClient / createSubscriptionClient are unchanged (they delegate with Nothing), so this is fully backwards compatible.
  • When the option is set, the HTTP link is split per operation type with a static header on each branch (same pattern as splitting on subscriptions). Subscriptions go over the websocket and are unaffected, as custom headers are not supported in websockets.

When the option is not set, behaviour is identical to before (no extra header).


🤖 This PR was generated by an AI agent (Claude Code) on behalf of Justin Garcia.

noisyscanner and others added 4 commits February 16, 2026 10:01
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
When set, HTTP requests carry the GraphQL operation type (query/mutation)
as the value of the given header, so a load balancer can route queries to
a read replica. Opt-in via new createClient'/createSubscriptionClient';
existing constructors are unchanged.
@finnhodgkin finnhodgkin merged commit 42df34c into OxfordAbstracts:main Jun 4, 2026
1 check passed
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.

3 participants