aerogear / offix

GraphQL Offline Client and Server
https://offix.dev
Apache License 2.0
758 stars 45 forks source link

Please support Nativescript Platform with offix and add description or example regarding the integration on website #434

Closed cjohn001 closed 3 years ago

cjohn001 commented 4 years ago

Hello together, I would like to give a feedback regarding the offix integration into a Nativescript app. I think if you like to bring people onto the native script plattform you would make things much easier if you provide an example on how this could be done, or at least add a description on how to integrate into nativescript on the offix website. I have not solved the offix integration yet, but made the first steps. In the datasync angular example, you load the offix client via a factory in an extra module with APP_INITIALIZER set on the provider. This approach does unfortunately not work for Nativescript, see the following description: //https://github.com/NativeScript/nativescript-angular/issues/1487 So the only possibility for preloading I have found yet is via a root resolver which I place as a preloader of the first app page ( after the login screen). Would be great if you could extend the offix page for Nativescript. In case you are interested I keep you informed what changes need to be made in contrast to your angular example. As Nativescript apps do not run in a browser several things unfortunately do not seem to work out of the box. For example the persistent storage will have to be different as well, as Nativescript neither does support localstorage nor IndexedDB nor React Native AsyncStorage. Hence I will probably need to write an interface to serialize to a sqlite database (seems like the only efficient storage available on Nativescript). I have also found no option yet to get the chrome apollo plugin working in order to view the apollo cache, which will make development quite painful. So if you have any ideas how I could get these things running, it would be great if you could provide some insights.

wtrocki commented 4 years ago

Thank you so much for creating amazing packages and researching this topic. We are evaluating bringing offix-angular into the offix (or linking to your repository) It is amazing to see community involvement.

We plan to do separate platforms as separate packages (especially native platforms like react native, capacitor and then nativescript).

I'm going to keep this issue and provide updates from the team

cjohn001 commented 4 years ago

Hello @wtrocki, one note regarding the offix-angular package. For the moment I would like to recommend to just link the repo on your website. I am currently using it to build a productive application. This is the ultimate chance to prove that the library works as expected. Having it in my hands allows me to make changes to it faster. Furthermore, I already know that I have to change things in the library to make full usage of offix. So far the library does not call offlinemutate and has no interface to add helper functions that create optimistic responses once offix is restarted again. I have seen your release discussion for offix 1.0. Maybe a good time to adopt would be once things work with apollo 3.0. Would be great if you could keep me informed once apollo 3 was integrated in offix. I will than also adopt offix-angular to it.

Best regards, Christoph

wtrocki commented 4 years ago

Yes. We trying to address cache issues in near future. Hopefully this will make it easy to integrate with platforms like Angular.

TBH I was also really impressed by your work to enable GraphQL-Code-Generator. It is something that we hoping to do for react as well

cjohn001 commented 4 years ago

GraphQL-Code-Generator is now working for me like a charm. Together with the extended apollo observables used in the offix-angular services, the integration is very nice. Can just recommend it. It now runs together with offix in the same way like shown in this video from the original maintainers:

https://www.youtube.com/watch?v=KGBPODrjtKA

I think in the future it might be interesting to see how much boilerplate for optimistic responses could also be generated. I have seen that in the offix package there are helpers for this available already. Just waiting for the next long weekend to get it working with my app :)

wtrocki commented 4 years ago

Yep.. Our target will be to integrate that with the queries that graphback generates and join offix together - this will give you data layer similar to Firebase API all very native to GraphQL. It is all possible thanks to GrapQL-Code-Generator that has support to various clients like URLQ, Apollo and thanks to that we can abstract individual client API and make people lives easier.

cjohn001 commented 4 years ago

Sounds great. Have you already fixed a timeline when you will adopt offix to apollo 3? I am currently looking pretty much into the cache to get my app developed. By doing so, I am a little worrying about all the garbage which remains in the cache when thinking on production environment use cases where the cache is the single source of truth for a longer time period. I have red about apollo 3 that it has garbage collection out of the box. Looks for me like we want to have it in Offix as soon as well :) You will be going to wait for the official Apollo 3 release?

wtrocki commented 4 years ago

Working on this as we speak. We going to provide updates on roadmap issues so feel free to watch it.

You will be going to wait for the official Apollo 3 release?

We will not however we struggle to get our PR's merged in their repo in order to be able to support Apollo 3.0. If we get that we will be able to integrate it fairly easily without forking entire apollo code ;D

cjohn001 commented 4 years ago

ok, great, than hopefully we will see the PRs in soon :)

kingsleyzissou commented 3 years ago

Hi @cjohn001, we have made the decision to move away from the Apollo client and we have decided to deprecate our Offix packages and release our Datastore. At the moment we don't have any plans to add Nativescript support for now. I will be closing this issue, but if you have any questions, please feel free to let us know.

You can see the docs for the updated datastore here: https://offix.dev/docs/getting-started