-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS App Using AWS Amplify DataStore Does Not Receive Subscriptions for Deletes Made via AWS Lambda #3759
Comments
Thank you for raising the issue with us. We look into it and provide an update. |
I did more testing and seems like Subscriptions works for create operation but update and delete aren't working. |
Thanks for providing that information too. To help us debug further, would you be able to provide any of the following?
|
Hi @rohit3d2003 Have you checked whether the records are updated or deleted in DynamoDB after the admin Lambda function was invoked? |
Yes, the records did get updated/deleted in dynamodb and they do show up if I restart the app. Conflict resolution has been set to Auto |
I am not seeing any activity in XCode console during updates/deleted with verbose logging. Only creates do show some activity in the console. Amplify Config |
To provide more context, in lambda function, I am signing in using Admin credentials and using the JWT token while calling the app sync apis so that from App Sync perspective, an Admin is making the change |
Hi @rohit3d2003 , How do you compose your GraphQL mutations to AppSync? Please keep in mind that the selection set of the GraphQL mutation should align with the GraphQL selection set of the subscription used by Amplify DataStore. This is crucial because there might be filters applied to the subscription to help Amplify filter real-time events from the AppSync real-time data server. Additionally, the subscription could include metadata fields that are necessary for Amplify DataStore to accurately parse the subscription event. Based on the GraphQL schema you provided, I suspect that the Amplify DataStore subscription includes a filter on the owner field. It might look something like this:
To ensure that Amplify successfully filters data events from the AppSync real-time data server, it is crucial to align the selection set in your GraphQL request with that of the Amplify DataStore subscription. Therefore, it better to be:
|
Thanks @5d! That was it, I was missing owner field in update and delete mutation and hence probably subscriptions were not received nor any error was showing up in console. This is fixed now |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
I'm using an AWS Amplify generated GraphQL API in my iOS application, which is configured to operate in offline mode using the DataStore approach. Additionally, I have several AWS Lambda functions that directly call AppSync queries and mutations to make changes to the data.
Problem:
When an object is deleted via an AWS Lambda function, the iOS app does not receive any subscription notifications, and the DataStore does not get updated with these changes. Specifically:
I am not sure if the auth rule on the model plays any part in it. So the record was created by owner but deleted by Admin from Lambda. Owner who is logged in to the iOS app not receiving these delete subscriptions/notifications.
Steps To Reproduce
Expected behavior
When an object is deleted via an AWS Lambda function, the iOS app should:
Amplify Framework Version
2.35.3
Amplify Categories
DataStore
Dependency manager
Swift PM
Swift version
5.0
CLI version
12.12.2
Xcode version
15.4
Relevant log output
No response
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
17.5
Device
iPhone 15
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: