Skip to content
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

[component] Chat #32

Open
4 of 5 tasks
hoodsy opened this issue Jul 13, 2018 · 13 comments
Open
4 of 5 tasks

[component] Chat #32

hoodsy opened this issue Jul 13, 2018 · 13 comments
Assignees

Comments

@hoodsy
Copy link
Contributor

hoodsy commented Jul 13, 2018

@hoodsy hoodsy created this issue from a note in Refactor Release (In progress) Jul 13, 2018
@hoodsy hoodsy changed the title [Dashboard] Chat [Teach] Chat Jul 13, 2018
@hoodsy hoodsy moved this from In progress to On Deck – v1 in Refactor Release Jul 13, 2018
@maticzav maticzav moved this from On Deck – v1 to In progress in Refactor Release Jul 19, 2018
@hoodsy hoodsy changed the title [Teach] Chat [component] Chat Jul 20, 2018
@hoodsy hoodsy moved this from In progress to On Deck – v1 in Refactor Release Jul 20, 2018
@hoodsy hoodsy moved this from On Deck – v1 to In progress in Refactor Release Jul 27, 2018
@hoodsy hoodsy mentioned this issue Jul 27, 2018
@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 27, 2018

@maticzav pollInterval question...

Right now, when a polling query is fired, we get the the 20 most recent messages. We need to append any new messages to our initial 20 messages.

For example:

  1. Initial query – 20 most recent messages
  2. User sends messages, other Users send messages
  3. Polling query – 10 new messages are appended to initial 20
  4. User sees 30 messages total

I'm thinking we will have to use some pagination, or something like that. Then our polling query would take an after argument.. Any thoughts?

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 27, 2018

It seems that pollInterval and fetchMore aren't meant to work together: apollographql/apollo-client#1087

Struggling with the best approach for getting fresh messages in Chat... I'll hold off until I get your input

@maticzav
Copy link
Contributor

Yea, I see. Tricky question haha; I think we already have pagination set up for messages. Couldn't we do it in two ways? Fetch more one way and polls on the other side?

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 27, 2018

I'm pretty sure the polling query overwrites the fetchMore, so that if we fetchMore and have 30 messages, the polling query will bring us back to 20.

The polling doesn't append... I'm thinking we could use fetchMore with an interval. Basically hack together our own polling.

There's probably a better way tho

@maticzav
Copy link
Contributor

Are you sure about this? I would assume they must have addressed this somehow - this is such a regular use case!

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 28, 2018

Basically, we have one query which has two parameters - endCursor and startCursor
endCursor is used for refetching, startCursor for loading more messages
Now, as far as I understand Apollo fetchMore accepts cursor variable and we have to update cache on our own - 💯 one down one to go
With polling, we could just change the endCursor and modify cache with updateQuery

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 29, 2018

@maticzav we may want to go for subscriptions... I'm struggling to find a way to make polling and updateQuery work

@maticzav
Copy link
Contributor

Have you found a way to solve this?

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 29, 2018

@maticzav I have not... I can begin exploring subscriptions but I would leave it to you to get the back end set up for subscriptions, unless you want me to mock out some resolvers and get subscriptions functional.

@maticzav
Copy link
Contributor

maticzav commented Aug 1, 2018

I totally missed the last message! I think we should still try to get the functionality without subscriptions. Maybe we could push back subscriptions for a little while and finish everything else first. Tell me what you think! 🙂

@hoodsy
Copy link
Contributor Author

hoodsy commented Aug 2, 2018

Yeah I'm feeling this too. Chat will be something we iterate on a lot!

@maticzav
Copy link
Contributor

maticzav commented Aug 2, 2018

Hey, I watched a Twitch stream last night and figured out we definitely need subscriptions. If we were to use polling instead, we could end up loading five messages at a time which is inferior user experience.

Tell me about your experience with subscriptions so far. I believe there's a portion of documentation that I should want to read before we jump into implementing it.

@hoodsy
Copy link
Contributor Author

hoodsy commented Aug 2, 2018

That's awesome to hear! I think it's important that we develop (and maintain) an understanding of other streaming products in the market, especially while streaming is relatively young.

Subscriptions worked quite well for me until I began dealing with some Prisma errors. They directed me to use polling as a workaround while they resolved potential memory leaks with subscriptions (I thiiink that was the issue).

Once I was able to get the resolver/Prisma side working for subscriptions, it was pretty much a breeze. The interface with <Query> and subscribeToMore was pretty straightforward. I don't think you'll have too much trouble with it!

One thing I think we should look out for is configuring the apollo-link and apollo-link-ws properly, but maybe that's a given. I had issues in the past uploading files depending on the order of my links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Refactor Release
  
In progress
Development

No branches or pull requests

2 participants