-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Remove reference to injectCacheManager from RelayEnvironment code comment #1030
Comments
I also can't find any clear documentation on the cache manager and how to implement it properly. Are there such resources? |
We're using a cache manager internally in our React Native apps, but the cache is external to Relay itself and very specific to our native FB product infrastructure, so we don't have much we can say about that. There is some evidence in Relay of the hooks that we've built in to enable that integration (and the reference to In fact, the mention of the "configurable cache manager" is probably unintentional in the If you look in
It has fire-and-forget methods for writing to the cache, and async methods for reading from it. I'd consider all of this to be subject to change, so I am reluctant to expose any of it on |
So there are no plans to have caching in relay? I've already implemented a |
Well, we do have it, but not inside Relay. The way we're trying to go moving forward is to make a small, modular, well-defined core upon which it is easy to build other abstractions (or compose inside existing abstractions). Offline caching is a good example of the kind of thing that we don't want in the core but we do want to be possible in "user space". Your use-case (ha, almost wrote use-cache) is very similar to the ones for which we use the disk cache (not strictly offline mode, but fulfilling queries with (potentially stale) data while we wait for fresh data to come back from the network. I am not sure what the limitations with respect to caching connections are. At a high level the API just deals with records, fields and root calls. @yuzhi knows the most about this so perhaps she can chime in on how this interoperates (or doesn't) with connections. |
As @wincent said, our plan here is to make it easier to build things like offline caching in user space, and I agree that we'd prefer not to expose the If you're trying to implement it anyway though - for connections you'll notice that the |
To chime in on caching the connection if you insist on implementing it externally. As Joe already mentioned, connection metadata is currently stored on a |
I'll look at |
There is no open source project for it. It is something we currently use in our React Native apps, like I said above, and it is specific to our native infra which is not part of Relay (or even React Native). |
This specific issue is closed now, but we'll keep the desire to have offline cache functionality on our radar, specifically in the context of refactoring Relay into a smaller core (#559) with this kind of functionality possible to build in "user space". |
The RelayEnvironment documentation states the following:
At the moment, the network layer and the task scheduler can be configured with
injectNetworkLayer
andinjectTaskScheduler
. Similarly the cache manager should have ainjectCacheManager
method.The text was updated successfully, but these errors were encountered: