DEV Community

Building Chatt - A Real-time Multi-user GraphQL Chat App

Nader Dabit on February 06, 2019

This repo and project is now archived One of the most popular use-cases of GraphQL subscriptions is building applications that enable real-tim...
Collapse
 
akhh profile image
akhh

Thanks for the post! I have one question with the subscriptions in Amplify/Appsync. Will the subscription automatically reassigned if there is an network issue? Or do you have to do it manually, e.g. listen for navigator.onLine for example?

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 ?

Collapse
 
liguoma profile image
Liguo-Ma

Hello Thanks for your post!
I have one question.
For one conversation I can not subscribe only 10 message.
After 10 messages I cannot subscribe onMessageCreate event:(
Please let me know what I should fix
Thanks

Collapse
 
ravnarayan profile image
ravnarayan

Hey @ Nader,

There are a couple errors, can you advise?

  • Attempted import error: 'compose' is not exported from 'react-apollo' -./src/index.js Module not found: Can't resolve 'aws-appsync-react' in 'C:\Users\my\my-project\aws-appsync-chat\src'

do you have a fix?

thank you,

Collapse
 
curlythemes profile image
Curly Themes

have you tested how aws appsync subscriptions can be used with vuex?

Collapse
 
dance2die profile image
Sung M. Kim

Thanks for the post & the open source app, Nader 👍

Would you also add "opensource" tag by chance?
as it could help people following the tag 🙂

Collapse
 
dabit3 profile image
Nader Dabit

Hey Sung, great idea. Updating now :).

Collapse
 
alsmith808 profile image
Alan Smith

Would it need a lot of tweekeing to work with DataStore, for my usecase I dont need realtime functionality, the conversation functionality is all I really need, thanks anyone.

Collapse
 
ronifintech profile image
Roni Yosofov

How do you generate messageConversationId? it seems to be a required field... what's the right way to generate this random id?