Closed JaEdmuva closed 4 years ago
Ah.. right. We kinda provided a workaround for that. Please see official docs: https://offix.dev/docs/react-native
We detect if an object is a string or object, but that will be a much better approach. As for the persistor itself: It is possible to provide persistor (using undocumented API). See here: https://github.com/aerogear/offix/issues/273
So TL;DR
@wtrocki about item 3. Yes, I can provide my own persistor, in fact I do. But there is an issue with that, which I do not fully understand yet. The thing is that when you first create the ApolloOfflineClient, you create a persistor with serialize: false
and It doesn't matter if I later define my own, it is already created.
Then (and it's my guess) the time comes when the first persistor still tries to read/write the cache to AsyncStorage and the exception comes, since it's trying to write an object (array) to the store but it only supports Strings. That'll be the main issue with RN I think.
@JaEdmuva we'll definitely work on allowing you to pass down the persistor options through the constructor. In the meantime did you try following the steps for passing in a custom storage mechanism in our react native document? This storage mechanism might help you get past the error you are seeing. See https://offix.dev/docs/react-native#integration
@JaEdmuva we recently merged and released https://github.com/aerogear/offix/pull/306 which allows you to create your own CachePersistor
object and pass it into the OfflineClient
constructor. You can check the PR description or the client configuration docs to learn how to do it. It can be used with version 0.13.1
I'm going to close this issue now, but please do not hesitate to reach out again with any more questions or feedback.
Feature Request
Is your feature request related to a problem? Please describe. I'm using v0.11.0. It is not possible to specify persistor options in the
ApolloOfflineClient
constructor. When using with react native, it is necessary to use a 'wrapper' to force serialization of data saved in AsyncStorage since the default options passed to the persistor has theserialize
option value asfalse
which causes a problem when persisting the cache data.Describe the solution you'd like Instead of having to define a 'wrapper' which is just a workaround, not a solution. Allow to define optional persistor options through the ApolloOfflineClient constructor. This will even solve #273
Describe alternatives you've considered None.