Skip to content

fix(typescript-apollo-angular): support apollo-angular v12+ combined parameter syntax#1355

Draft
andreialecu wants to merge 5 commits intodotansimha:mainfrom
andreialecu:claude/fix-watch-query-options-v12-9c8GM
Draft

fix(typescript-apollo-angular): support apollo-angular v12+ combined parameter syntax#1355
andreialecu wants to merge 5 commits intodotansimha:mainfrom
andreialecu:claude/fix-watch-query-options-v12-9c8GM

Conversation

@andreialecu
Copy link

Description

This PR adds support for apollo-angular v12+ which introduced a breaking change where all method parameters must be combined into a single options object with variables nested within the variables property.

The solution maintains backward compatibility - SDK method signatures remain unchanged (variables, options as separate parameters), but internally the arguments are combined when calling apollo-angular v12+ methods.

Related #1354 and #306

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added 4 new test cases:

  • should combine variables into options for apolloAngularVersion 12+
  • should combine variables into options for mutations with apolloAngularVersion 12+
  • should combine variables into options for subscriptions with apolloAngularVersion 12+
  • should use legacy call syntax for apolloAngularVersion below 12

All 31 tests pass.

Test Environment:

  • OS: Linux
  • @graphql-codegen/typescript-apollo-angular: local
  • NodeJS: 20+

Checklist:

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Further comments

For apolloAngularVersion >= 12:

// Generated SDK method (signature unchanged)
myFeed(variables?: MyFeedQueryVariables, options?: QueryOptionsAlone<MyFeedQueryVariables>) {
  return this.myFeedGql.fetch({ ...options, variables })  // Combined internally
}

… v12+

For apollo-angular v12 and above, add the `extends ApolloCore.OperationVariables`
constraint to the generic type parameter V in the SDK type interfaces
(WatchQueryOptionsAlone, QueryOptionsAlone, MutationOptionsAlone,
SubscriptionOptionsAlone).

This change is conditional and only applies when `apolloAngularVersion: 12`
or higher is configured, maintaining backward compatibility with earlier versions.

Fixes dotansimha#1354
…r v12+

Apollo-angular v12 introduced a breaking change where all method parameters
must be combined into a single options object, with variables nested within
the `variables` property.

For apolloAngularVersion >= 12:
- SDK methods now take a single options parameter instead of separate
  variables and options parameters
- Interface types only omit 'query'/'mutation' (not 'variables') since
  variables are now part of the options object

Example change for generated SDK methods:
- Old: myQuery.fetch(variables, options)
- New: myQuery.fetch(options) where options.variables contains the variables

Fixes dotansimha#1354
…ally for v12+

Maintains backward-compatible SDK method signatures (variables, options)
while internally combining them into a single options object when calling
apollo-angular v12+ methods.

For apolloAngularVersion >= 12:
- SDK method signatures remain: myQuery(variables, options)
- Internal call becomes: this.service.fetch({ ...options, variables })

For apolloAngularVersion < 12:
- Everything remains unchanged: this.service.fetch(variables, options)

This ensures no breaking changes to consumer code while supporting the
apollo-angular v12+ combined parameter syntax requirement.

Fixes dotansimha#1354
@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 738863f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/typescript-apollo-angular Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@andreialecu andreialecu marked this pull request as draft January 28, 2026 11:28
… v12+

For apollo-angular v12+ with Apollo Client 4:
- Use type aliases with Apollo.Apollo namespace types instead of ApolloCore
- All OptionsAlone types have <T, V> signature for proper type inference
- Watch methods have explicit return type (Apollo.QueryRef<T, V>)

Type mappings for v12+:
- WatchQueryOptionsAlone -> Apollo.Apollo.WatchQueryOptions
- QueryOptionsAlone -> Apollo.Apollo.QueryOptions
- MutationOptionsAlone -> Apollo.Apollo.MutateOptions
- SubscriptionOptionsAlone -> Apollo.Apollo.SubscribeOptions

Fixes dotansimha#1354
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.

2 participants