aerogear / offix

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

How to set apollo-cache-persist options like maxSize, debug, debounce, trigger #273

Closed krunaldodiya closed 4 years ago

krunaldodiya commented 4 years ago

How to set apollo-cache-persist options like maxSize, debug, debounce, trigger in react native app ?

wtrocki commented 4 years ago

Sadly there is no public api for that but it is very easy to do it.

Persistor is public so.. you can set new Persistor with custom options: https://github.com/aerogear/offix/blob/master/packages/offix-client/src/ApolloOfflineClient.ts#L52-L58

Swapping persistor needs to happen before calling init function as it is used there: https://github.com/aerogear/offix/blob/master/packages/offix-client/src/ApolloOfflineClient.ts#L73-L76

EDIT: Links above pointing to master version - 0.10.0 will have small differences in config sturcture

krunaldodiya commented 4 years ago

Thanks, I will try and let you know

wtrocki commented 4 years ago

@darahayes IMHO we might need to document this issue

darahayes commented 4 years ago

@kunaldodiya we recently merged and released https://github.com/aerogear/offix/pull/306 (in version 0.13.1) which allows you to create your own CachePersistor object and pass it into the OfflineClient constructor. This should let you set whatever options you require for cache persistence. You can check the PR description or the client configuration docs to learn how to do it. I'm going to close this issue now but please do reach out if you have any further questions/feedback/issues.