-
Notifications
You must be signed in to change notification settings - Fork 247
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
DataStore subscription does not work for only a few models. #5256
Comments
Hi @BatuhancanG, thank you for submitting this issue, we will take a look at this issue and get back to you with any updates or questions. |
@BatuhancanG I'm investigating this issue and while working to build the data backend with CLI Gen 2 I faced some issue with the data model. to be able to deploy the data backend successfully I needed to make the following updates:
here the Gen 2 data model that I have and was able to deploy it successfully.
While we are investigating this issue would you please confirm that the data model you provided is up to date and you were able to deploy your data backend successfully using the provided data model? |
Hi, thank you for your response. I’m not using Gen2. I’m developing my project with Gen1. I don’t know if this makes a difference, but I wanted to mention it. Also, the relations in my User model were correct initially, but whenever I make changes to the database, the relations break. It’s only the relations with the User model that get broken. I think this is a other issue. I recorded a video to help you understand the problem better, and I’m attaching it as well. As you suggested, I changed HucodeNotification to Notification and fixed the relations in the user model, but the problem still persists. This issue only occurs with the Message part. It doesn’t happen with Conversation or with subscriptions for other models. I’ve recorded a video to show the situation as well, where you can see that all the messages are saved to the database, but the other party doesn’t receive them in real-time. Additionally, after changing the name of Notification, I started getting an error in Amplify Studio. I'm attaching a screenshot of the error as well. 2024-08-24.15-10-49.mp42024-08-24.13-40-56.mp4 |
Hello @BatuhancanG. You would not necessarily need to make a new request on each change. You could do the following instead:
This is how observeQuery works under the hood. If there were an observeQuery like API available in the API category, would the API category meet your needs? |
We do have an open feature request for an observeQuery like API: #2414 Feel free to give the issue a 👍 and leave a comment with your use case. This helps us prioritize issues and requests. |
Hi, thank you for your answer. |
I understand that it is extra workload. If an API existed within the API category (similar to observeQuery) that removed the need to maintain 3 separate subscriptions and make the initial query each time the app was opened, would that remove your need for DataStore? DataStore is an offline first solution. A typical use case for offline first would be an app where users of the app are commonly offline for multiple days at a time and need to maintain the ability to read and write data. If you do not have a use case that requires offline first, we typically recommend using GraphQL API directly as it is more flexible. |
Hello, can someone help me? Nobody has gotten back to me yet. |
@BatuhancanG we have an open feature request for GraphQL API support sorting by secondary index, #4942. in your case can you use a query predicate on the Message timestamp as an alternative solution? (I understand it does not satisfay the limit=10 that you can do with the DataStore) |
Hi @BatuhancanG, we have a guide on how to manually setup sorting in API. I recognize this is not as slick as our other APIs, but hopefully this unblocks you until we implement better support. |
Description
Hi everyone,
I'm using DataStore subscriptions in my project to enable real-time chat for users. Initially, messages were not arriving in real-time, but after deleting and re-adding the conversation and message models from the database, neither conversations nor messages are being delivered in real-time anymore.(While it was not working just for the message before, deleting the entire database and adding it again solved my problem.) During this time, I can see that messages and conversations are being created in the database in real-time through Amplify Studio. I am not getting any errors within the application. But if i use GraphQL subscription to do that, it works correctly. What could be the reason for this? I am adding video recording and screenshot for understanding easily.
2024-08-12.13-38-11.mp4
Categories
Steps to Reproduce
I am adding the code I wrote for the conversation subscription, and I am using a similar code for the message (I am using riverpod to do that. i also tried to use it like in Amplify Documentation but result doesn't change.).
Screenshots
2024-08-12.13-38-11.mp4
Platforms
Flutter Version
3.22.3
Amplify Flutter Version
2.3.0
Deployment Method
Amplify CLI
Schema
The text was updated successfully, but these errors were encountered: