Configure multiple network layers in Relay Modern

I am using an adaptive application with a modern relay.

Currently, our implementation of app fetchQuery just makes a selection on the network (e.g. https://facebook.imtqy.com/relay/docs/en/network-layer.html )

Although it is possible to use a different level of the local network, for example https://github.com/relay-tools/relay-local-schema , which returns data from a local db, such as sqlite / realm.

Is there a way to configure an offline response from the local network level, and then automatically query the real network, which also fills the storage with more recent data (along with writing to local-db)? Should / should they use the same store?

From the requirements of Network.create (), it should return a promise containing the payload, there is no way to return multiple values.

Any ideas / help / suggestions are welcome.

+5
source share
1 answer

The fact that you are trying to achieve your difficult, and it’s bad to go for a simple approach, which is a long-term cache.

As you may know that relay modern uses local storage and an exact copy of the data you retrieve, you can configure this storage cache according to your needs, without a mutation cache.

To understand how this is achieved, the best library to set up Relay Modern or the classic network layer can be found at https://github.com/nodkz/react-relay-network-modern p>

My recommendation: configure the cache and see your request ... (you will like it)

Thinking in a relay, https://facebook.imtqy.com/relay/docs/en/thinking-in-relay.html

0
source

Source: https://habr.com/ru/post/1276000/


All Articles