Skip to content

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

@andreialecu

Description

@andreialecu

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:

- 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions