dotansimha / dotansimha/graphql-code-generator-community

Support apollo-angular v12's new combined parameter syntax and breaking changes

Open
#1,354 4 comments 5 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

**Is your feature request related to a problem? Please describe.**

apollo-angular v12 introduced a breaking change in the signature of generated Query, Mutation, and Subscription services: All parameters are now combined into a single options object, meaning variables must be nested within the `variables` property. For example:

```diff
- myQuery.watch({ myVariable: 'foo' }, { fetchPolicy: 'cache-and-network' });
+ myQuery.watch({ variables: { myVariable: 'foo' }, fetchPolicy: 'cache-and-network' })

- myMutation.mutate({ myVariable: 'foo' }, { errorPolicy: 'ignore' });
+ myMutation.mutate({ variables: { myVariable: 'foo' }, errorPolicy: 'ignore' });

- mySubscription.subscribe({ myVariable: 'foo' }, { fetchPolicy: 'network-only' });
+ mySubscription.subscribe({ variables: { myVariable: 'foo' }, fetchPolicy: 'network-only' });
```

Currently, `@graphql-codegen/typescript-apollo-angular` does not generate code compatible with this change even when setting the `apolloAngularVersion` config. The old, deprecated parameter style is still used in output.

**Describe the solution you'd like**

- Add support for apollo-angular v12 in the codegen plugin under the `apolloAngularVersion: 12` config (and above, as needed).
- When this version is set, generate service methods that combine all parameters into a single options object, matching the new apollo-angular v13 signature requirements (`variables` property nested inside options).
- Document this breaking change in the plugin readme and migration guides.

**Describe alternatives you've considered**

- Staying on apollo-angular v11 and below (not desirable)
- Manually wrapping all generated services (not scalable if there are many operations)

**Additional context**

- Provided by official migration notes and breaking change docs: https://github.com/the-guild-org/apollo-angular/releases/tag/apollo-angular%4012.0.0
- This change is necessary for users upgrading Angular and apollo-angular to v12+.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.