aws / aws/aws-appsync-community
Subscriptions omit fields that have aliases in the corresponding mutation(s)
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
## Description
When using a field alias in the selection set of a mutation, I believe the corresponding subscription(s) are being sent the value in the field alias, rather than the field, preventing the subscription from being able to receive the desired field, at least using pure WebSockets.
## Simple Example
### Schema
```graphql
type A { b: String }
type Mutation { a: A }
type Subscription { a: A @aws_subscribe(mutations: ["a"]) }
```
### Mutation
```graphql
mutation { a { bAlias: b } }
```
### Subscriptions
```graphql
subscription { a { b } }
```
or
```graphql
subscription { a { bAlias: b } }
```
These subscriptions will get a null value for `b` and `bAlias`, respectively, as I believe the mutation's selection set is causing `bAlias` to be available to the subscription, instead of `b`, and you cannot submit a valid subscription requesting `bAlias` as that does not exist in the schema.
## Problem Case
### Schema
```graphql
type A { x: Int }
type B { x: Float }
union C = A | B
type Mutation { c: C }
type Subscription { c: C @aws_subscribe(mutations: ["c"]) }
```
### Mutation
```graphql
mutation { c { ... on A { xInt: x } ... on B { xFloat: x } } }
```
### Subscription
```graphql
subscription { c { ... on A { xInt: x } ... on B { xFloat: x } } }
```
Here, we have to use field aliases to get all fields, but it won't work in the subscription.
Contributor guide
Research direction
No repository files or tests are identified in the issue. Reproduce the simple and union examples over pure WebSockets, then trace how mutation selection sets are forwarded to subscriptions; done means subscriptions receive the schema field values regardless of mutation aliases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100