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

How to achieve offline support? #11

Closed
Bessonov opened this issue Jul 27, 2018 · 14 comments
Closed

How to achieve offline support? #11

Bessonov opened this issue Jul 27, 2018 · 14 comments
Labels
project-apollo-client (legacy) LEGACY TAG DO NOT USE

Comments

@Bessonov
Copy link

Bessonov commented Jul 27, 2018

Migrated from: apollographql/apollo-client#424
and
Migrated from: apollographql/apollo-client#2460
and
apollographql/apollo-client#307

Please vote with 👍, if this feature request important for you.

@Bessonov
Copy link
Author

Hey, @jbaxleyiii, you've marked apollographql/apollo-client#2460 as "high-priority". Is there any progress on this?

@Bessonov
Copy link
Author

Related apollographql/apollo-link#125

@Bessonov
Copy link
Author

Bessonov commented Jul 27, 2018

Good answer to the question what offline support means: apollographql/apollo-client#424 (comment) . Next answers provide some examples of syncing DBs like PouchDB/CouchDB and minimongo/MongoDB in Meteor.

Other syncing solutions: prisma/prisma1#1659 (comment) and https://github.com/orbitjs/orbit

@jamesreggio
Copy link

Here's a comment I wrote about how you can cobble together pretty decent offline support with packages that are already available today: https://github.com/benseitz/apollo-link-offline/issues/1#issuecomment-371678922

@Bessonov
Copy link
Author

Bessonov commented Nov 6, 2018

From @chrisfosterelli / https://github.com/benseitz/apollo-link-offline/issues/1#issuecomment-436421802

We spent some time building our application for full offline with React Apollo's new and components. We got offline mutations to persist across refreshes using a wrapper around the default Mutation component.

In case it's useful to anyone else, we wrote about how we got that to work in detail here: https://medium.com/twostoryrobot/a-recipe-for-offline-support-in-react-apollo-571ad7e6f7f4

@sebas5384
Copy link

We are working on this lib to get granular offline support (still wip):
https://github.com/TallerWebSolutions/apollo-cache-instorage

@morrys
Copy link

morrys commented Jul 12, 2019

Hi everyone,
these days I created these libraries to manage both cache persistence and offline support:

https://github.com/morrys/wora/tree/master/packages/apollo-offline

https://github.com/morrys/wora/tree/master/packages/apollo-cache

They are projects born by extracting the logics of the offline support from:

https://github.com/morrys/react-relay-offline

You can find a first example project here:

https://github.com/morrys/offline-examples

A very important feature is the integration of the offline engine within the client logic and not at the network level.

Your opinions on both libraries are welcome.

For more information contact me on twitter: https://twitter.com/m0rrys

Thank you,
Lorenzo

@wtrocki
Copy link

wtrocki commented Jul 17, 2019

The alternative will be to use https://github.com/aerogear/offix/

It supports offline persistence, subscriptions, data encryption and conflict resolution.

@loganpowell
Copy link

@wtrocki offix lookin' pretty sweet

@mbret
Copy link

mbret commented Nov 5, 2020

Offix officially stated they would move away from apollo and not support the v3. I guess we are still in need of some offline features from apollo framework then.

@tennox
Copy link

tennox commented Dec 7, 2020

Offix officially stated they would move away from apollo and not support the v3.

I think that's not fully accurate: aerogear/offix#543 (comment)

@wtrocki
Copy link

wtrocki commented Dec 8, 2020

TL;DR - Offix got feedback from the community that:

  • Offline read is the most anticipated feature
  • Offline writes are usually only for some small parts of the app.
  • If the app needs to be fully offline using the existing Apollo API to deliver offline is challenging as it wasn't designed to cover this case

We are doing an offline database solution rather than just adding an offline layer on top of the Apollo.

Status of offline support for Apollo

There are 4 levels of offline support right now

  1. InMemoryCache (will keep things cached until website/app is restarted)

Supported by Apollo. CacheRedirects giving developers some form of customization for advanced use cases

  1. ApolloCachePersist (persist cache and restores it on startup)

Offline without write access - supported by Apollo Community (good work from @wodCZ who recently fixed dozens of bugs)

  1. Community extensions for supporting offline writes

Wora library done by @morrys seems to be the most popular choice. Challenges of those solutions
were that we were relying on some internal Apollo Client API that might change etc. and general experience is still not the best as offline applications behave differently even when online etc.
Offix community usually wanted to have offline capabilities only for some small chunks of schema etc.
This type of library was proven to be really hard to maintain for Offix so we moved to level 4

  1. Realtime Database

This one uses GraphQL as transport and uses an offline database (think Firebase, AppSync, etc.)
This is the path we trying to with the https://offix.dev and hope that we can provide something that will complement level 1 and 2, while avoiding maintenance hell and complexity of level 3.

The benefits of those is that you can use Apollo client on level 1 and enable database only for the elements of the system that really needs to be fully offline etc. This approach was proven to be successful for folks that wanted to have a flexible and stable solution.

Initially, we build this on the backend using our own implementation: https://graphback.dev/docs/datasync/intro but we are also investigating using Apache Kafka

I hope that at some point the Apollo team would take over and offer level 2 along with level 1 as this is the most requested feature IMHO.

@mbret
Copy link

mbret commented Dec 8, 2020

After playing for couple of month with Apollo trying to achieve an offline first app I decided to drop it as I was facing more and more challenge every day while having a very fragile and gigantic code base just to deal with it. This one is probably on me tho, I should have understand better what is apollo designed for before picking it.

I completely switched to rxjs and I was able to reduce my code base by about 60% for the same features.

@wtrocki I wish you the best with your new offix and I will certainly follow your work. Offline world is truly a challenging one.

@hwillson
Copy link
Member

Hi all - we're going to be looking into this in the not too distant future. We'll be tracking this work in #371. Please join in the discussion over there if you're still interested in this functionality. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project-apollo-client (legacy) LEGACY TAG DO NOT USE
Projects
None yet
Development

No branches or pull requests

9 participants