DEV Community

Discussion on: Building Chatt - A Real-time Multi-user GraphQL Chat App

Collapse
 
realironnam profile image
Nam NV

Thank for sharing.
In my case, I have a 1000 conversation in chat history and each conversation have multiple user
So If I using appsync as your post, I need to make 1000 subscription for each user (it's bad if I doing like that)
As I known that appsync is not support to subscription with array ID (onCreateMessage($messageConversationId: ID!))

So my solution for this case:

  1. writing lambda function with name actionCreateMessage for mutation createMessage
  2. Add type PubMessage {userId, message} with subscription and create mutation
  3. actionCreateMessage will do:
  4. getting list user of conversation
  5. call createPubMessage for each user
  6. in client using only one subscription onPubMessage(userId: ID!)

@dabit3 Could you help to advice me ? Is there any better solution for that used appsync ?