Im currently evaluating AWS AppSync as a backend solution for a messaging app.
The users will have a view to explore new Chat Groups and a different view where they see a list of their joined and private Chats (In the list the name and the last message of the chats should be displayed). Each Chat will of course have a detail view where all the messages are displayed.
The question is how to design the subscription part. My Mutation to send a message will look something like this:
createMessage(
content: String,
conversationId: ID!,
createdAt: String!,
id: ID!
): Message
According to the subscription docs i only have two possibilities to design my subscription. Either i subscribe to all new messages or to all new messages from a specific conversation by using the conversation id as an argument. So in my case i would need to fetch all the user conversations and then make a subscription call for every single conversation. Somehow this feels like a problem, but I don't see a different way (e.g. Custom filtering is not possible currently (according to this link))
Is there a better way to subscribe to new messages for a specific subset of messages (only in conversations im subscribed to)? Is having potentially 100s of active subscriptions on the client a problem?
Thanks in advance Luca
You are correct. The only two ways to do this out of the box is to:
If you subscribe to each conversation using an argument (option #1), you can batch send the subscribe requests in one HTTP request. E.g. Send up to 50 subscriptions with different conversation arguments in one request.
There is a third option, where you can do more work to ensure client efficiency. This option involves setting up a reverse index of conversations to client.