-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: add new messages to ui as soon as theyre sent without waiting for subscribtion update #37
Conversation
…or subscribtion update
By looking at this PR I was feeling there must be a more generic way. And I found this, did you try it? |
Yeah, I tried with that and with direct cache access. It turned out it works with queries, not subscriptions ¯_(ツ)_/¯ I had some other thoughts how to do it in 'generic way'. My idea was to use both query and subscribtion at the same time (hasura allows that, you only have to gql.replace( Then I thought to start simple and add some solution like above if more similar use-cases emerge. But TBH I'm not sure and I'm not fully happy with this PR too. |
The fact we need to follow the payload schema with the |
Basically, the solution presented in the PR is not sustainable enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall.
I agree with @koliada . The PR looks ok, but implementing the other way solution and making it generic so that it could be applied in the future in other components probably makes more sense. |
@@ -43,7 +43,8 @@ | |||
"styled-normalize": "^8.0.7", | |||
"styled-reset": "^4.3.4", | |||
"subscriptions-transport-ws": "^0.9.18", | |||
"react-hook-form": "^7.0.6" | |||
"react-hook-form": "^7.0.6", | |||
"immer": "^9.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to sort the manually added dependencies for better visibility :)
@pie6k what's your take on this? Would you like to re-implement this or leave it be for now? I don't have a strong opinion on this. |
I think I'll re-implement and use this opportunity to organize graphql definitions and hooks in a bit different way (we've been discussing it a bit recently, but I can elaborate) |
Sounds good. Writing it down, what you would like to change, would help me to participate in the discussion. |
Fair, added context to https://meetnomore.com/room/ptTTTfy12hdK3mv347R5 > graphql agenda point (:< not able to get link to agenda point) |
I'll redo this work with different graphql approach |
What changed:
Before: after sending a new message, it was not showing in the UI until the socket subscription picked it. Hasura has 1s socket interval so it often had a visual delay
Now: as soon as mutation resolved, data from mutation is added to the temporary list of 'optimistic messages' to display in the UI .