-
Notifications
You must be signed in to change notification settings - Fork 144
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
[Suggestion] Offline-First Application #926
Comments
@morrys that is awesome! First step - how and where do you think we should integrate it into the script of the WhatsApp clone? We have the chapter about caching with Apollo client here: https://www.tortilla.academy/Urigo/WhatsApp-Clone-Tutorial/master/next/step/7 Then mutations here: https://www.tortilla.academy/Urigo/WhatsApp-Clone-Tutorial/master/next/step/8 Live updates with subscriptions here: https://www.tortilla.academy/Urigo/WhatsApp-Clone-Tutorial/master/next/step/10 And adding and removing chats here: https://www.tortilla.academy/Urigo/WhatsApp-Clone-Tutorial/master/next/step/12 Do you think it's worth a separate chapter? my tendency says yes but maybe you think it's better to integrate into an existing one? My first thought is putting after all of those chapters I've mentioned above to demonstrate offline handling for all of those actions. Let's start with a doc where we write the rough script for that chapter. |
I also think that a separate chapter is better so you can highlight all the changes necessary to manage offline |
@morrys There are lots of approaches to the offline problem. Can you explain how Do you have some more info about this project is resolving offline problem?
We have that done for apollo-cache-persist so you can reuse some of the code. I will be really excited to collaborate with you to build a fully functional offline library. I'm the maintainer of Apollo Cache Persist and I would love to bring some of your ideas directly into apollo cache persist. I'm one of the authors of https://github.com/aerogear/offix (we have been apollo-offline before but we needed to rename because we did not get permission to use Apollo name). We are working on offix for more than a year and still exploring the challenges of offline and data replication. The biggest challenge for us was actually to stay up to date with Apollo. Version 3.0 that is coming soon is also going to break a lot of stuff for the caching layer. I really like that you are swapping Apollo Cache and I would like to apply some of the patterns you have employed to offix. As for the original issue, I think we can approach offline problem in many ways here:
I personally think that state management problem is the most important here - users can simply use local state to save some data and replicate that to a server when ready. This is where https://github.com/kamilkisiela/loona can play some role. I think instead of talking here what package we should be using we can focus on the what approach for offline we want to present for a wider audience that might look for some generic cases. In many cases, offline can mean Query caching and state management. Persistent mutations have so many side issues and bugs that for some community members we were advising against using offix and instead follow up lightweight RetryLink based https://github.com/carvajalconsultants/apollo-link-offline |
Hi @wtrocki, nice to meet you. a small premise is due, no library can completely solve offline problem. The main objective of The second goal is to help integrate new functionality or extend the configurability of the relay and apollo libraries. This is to ensure greater stability of the library and focus exclusively on issues related to the offline. Collaborating is the real strength of open source :) (Https://github.com/apollographql/apollo-feature-requests/issues/154) I kindly ask you to open the issues on my repository as it is a discussion involving more than one package. |
From my point of view using wora or any other offline lib in whatsapp clone will be overkill and lead to a different architecture than the messaging app will need. Usually, graphql messaging apps will need to have some logic to monitor subscription connection and then enqueue messages in the local state. Then users can manually trigger to resend them or have a periodical check to send them again. Network state checks here are not reliable as we might have a network but not being able to push messages at all (very common problem for messaging apps). I was personally hoping to extend What's Up clone to get offline cases and IMHO the best way to do so is to do it without any library apart from Apollo-Cache-Persist. I have implemented GraphQL messaging app before and what really worked for me was NetworkState aware subscription feature we thinking to add in next release of the offix. I'm happy to add offline support to what'sup clone but I would hope to use just state library and Apollo cache. Version 3.0 will shake things up so we can avoid doing a lots of work that will deprecate so fast and introduce many breaking changes in tutorial. This way we get:
I will be hoping to have something that makes Whatapp clone simple and maintainable over the time. Messages (optimistic responses) will disappear after restart of the application (in offix we have some workarounds for that, however, if we separate local state from the network cache we can get that seamlessly without any library. |
Hi again, first let me say I'm really happy about this discussion - This is exactly the reason I've created this clone! First some general comments on the purpose of the clone: That means that it's true that there are the messaging offline capabilities but I don't want to settle with just those - I want to add more features to the WhatsApp that cover also other, more advance use cases. Some thoughts about Apollo 3.0:
For those reasons my first priority is to have as many use cases and features on the clone as possible. So that's where I need to help first. I've created a public doc on GDocs where we can list all of the libraries, use cases and features we can think of. Please help me and let's collaborate on this: https://docs.google.com/document/d/1AEv6fwrl3tDMN3-o_WMFGjnBFmaDRTocg0JXGm5gxJg/edit |
After reading all the details I think we can collab together with @morrys to add offline support and conflict resolution to whatsapp clone |
Hi everyone, Even the management of possible conflicts is very limited. A theme that will be very interesting instead will be the subscription. Saturday I will dedicate it to the document but in my opinion it is better to avoid listing all the problems and theories on the offline but to proceed with explaining the first necessary step and during its realization we will highlight some problems that we will face in the next step. This will lead us to evolve the tutorial gradually and put the conditions of people to understand both the problem and its resolution. |
This is really good suggestion that really basing on my previous post. I wanted to start with something that will not overload people with too many offline concepts and features. Having PR with something opens conversation - let's work together on this. |
@Urigo Hi everyone, Today I decided to fork the two repositories and create the first version of whatsapp offline. This is commit sufficient to make the application offline This is the commit to generate client side IDs, I also added the optimistic response to the chat cancellation. This commit in the server to manage the IDs sent by the client. Surely the service worker needs to be accommodated for a better offline experience. As you can see, it took only a few modifications, let me know your opinion. Lorenzo |
@morrys that's amazing! thank you so much! |
Hi all,
I wanted to propose to integrate my library into your project https://github.com/morrys/wora/tree/master/packages/apollo-offline
I think that in a chat it is very important to be able to look at messages and send new ones even if the internet connection is absent.
I also have a version for Relay Modern: https://github.com/morrys/react-relay-offline
I am available to carry out and / or help with integration.
I await your opinion about it,
thank you
Lorenzo
The text was updated successfully, but these errors were encountered: