fix(typescript-apollo-angular): support apollo-angular v12+ combined parameter syntax#1355
Draft
andreialecu wants to merge 5 commits intodotansimha:mainfrom
Draft
Conversation
… 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 detectedLatest commit: 738863f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
… 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
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 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
variablesproperty.The solution maintains backward compatibility - SDK method signatures remain unchanged (
variables,optionsas separate parameters), but internally the arguments are combined when calling apollo-angular v12+ methods.Related #1354 and #306
Type of change
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 12All 31 tests pass.
Test Environment:
@graphql-codegen/typescript-apollo-angular: localChecklist:
Further comments
For
apolloAngularVersion >= 12: