-
Notifications
You must be signed in to change notification settings - Fork 266
Description
This issue is caused by that platform libraries generating incompatible selection set making mutation requests.
In most cases, especially when nested models are involved, iOS platform cannot receive subscription updates from mutations made in other platforms, such as amplify-js (Amplify Studio), amplify-android.
Describe the bug
Saving nested models in Android may raise GraphQL error for iOS devices that subscribe to the same models. It happens when saving nested models in Android, and receiving subscription message in iOS.
Expand for details
This is due to Android doesn't populate nested models by default, when saving object, service side GraphQL validation may fail due to missing fields in the request sent from Android. The error may be emitted to all model subscriptions in different devices.
Two possible causes:
- In Android, nested models (has-one, belongs-to) are not populated with data
- When saving an object with creating association with other models, complete objects of other models see to be required, but no associating only by
idfield
Android sent mutation that caused the error
{
"query": "mutation CreateComment($input: CreateCommentInput!) {\n createComment(input: $input) {\n _deleted\n _lastChangedAt\n _version\n content\n id\n post {\n id\n }\n }\n}\n",
"variables": {
"input": {
"id": "2a7693b3-0591-4941-901e-fb355c962f72",
"postID": "a4930282-77ea-468d-88e2-c042a8e575a5",
"content": "tetetet"
}
}
}To Reproduce
Steps to reproduce the behavior:
- Run
amplify_datastorewith API sync in 1 Android emulator and 1 iOS simulator - Save a new "Comment" in Android emulator
- Observe iOS simulator logs
- See error
2021-06-22 12:59:28.065189-0700 Runner[5863:11863431] [StarscreamAdapter] websocketDidReceiveMessage: - {"id":"13C8F47B-5693-4925-9818-9A404031CC15","type":"data","payload":{"data":{"onCreateComment":{"id":"8360f342-5515-4a49-98e1-906211efd408","content":"Test","post":null,"__typename":"Comment","_version":1,"_deleted":null,"_lastChangedAt":1624391967947}},"errors":[{"message":"Cannot return null for non-nullable type: 'Int' within parent 'Post' (/onCreateComment/post/rating)","path":["onCreateComment","post","rating"]},{"message":"Cannot return null for non-nullable type: 'String' within parent 'Post' (/onCreateComment/post/title)","path":["onCreateComment","post","title"]},{"message":"Cannot return null for non-nullable type: 'Person' within parent 'Post' (/onCreateComment/post/author)","path":["onCreateComment","post","author"]},{"message":"Cannot return null for non-nullable type: 'Int' within parent 'Post' (/onCreateComment/post/_version)","path":["onCreateComment","post","_version"]},{"message":"Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'Post' (/onCreateComment/post/_lastChangedAt)","path":["onCreateComment","post","_lastChangedAt"]}]}}
Expected behavior
iOS should receive correct subscription message.
Platform
Amplify Flutter current supports iOS and Android. This issue is reproducible in (check all that apply):
[ x ] Android
[ x ] iOS