aws / aws/aws-appsync-community
Creation mutation missing internal fields for onCreate subscription to work
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
**Issue**
When running the mutation below on the AppSync Console
```
mutation createRestaurant {
createRestaurant(input: {
name: "Nobu"
description: "Great Sushi"
city: "New York"
}) {
id name description city
}
}
```
On the client complaints missing internal fields while using a creation subscription:
- "Cannot return null for non-nullable type: 'AWSDateTime' within parent 'Restaurant' (/onCreateRestaurant/createdAt)"
- "Cannot return null for non-nullable type: 'AWSDateTime' within parent 'Restaurant' (/onCreateRestaurant/updatedAt)"
The issue seems to be that type on the project is defined as
```
type Restaurant @model {
id: ID!
name: String!
description: String!
city: String!
}
```
But on the AppSync Console appears as
```
type Restaurant {
id: ID!
name: String!
description: String!
city: String!
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
```
**Fix**
You can fix this by adding the missing fields but this is quite unexpected as these are internal fields.
```
mutation createRestaurant {
createRestaurant(input: {
name: "Nobu"
description: "Great Sushi"
city: "New York"
}) {
id name description city
createdAt updatedAt <====
}
}
```
Contributor guide
Research direction
Start in the AppSync Console with the shown createRestaurant mutation and onCreateRestaurant subscription, then compare the declared Restaurant schema with the generated schema. Reproduce the missing createdAt and updatedAt values and determine the expected internal-field behavior; done means the creation subscription no longer returns null for those non-nullable fields without requiring them in the client mutation selection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100