Skip to content

Discussion - using Relay offline #676

@zuhair-naqvi

Description

@zuhair-naqvi

We're planning to use Relay for a messaging application we're building with React Native. As you'd assume the 2 things that are key to achieving this are subscriptions and offline support both of which seem to be in the works.

We'd love to contribute to these efforts but need some validation if the below proposal could work for offline support or if it's plain stupid!

Inject a custom network layer that does the following before handing queries and mutations over to Relay's default network layer:

Queries:

  1. When online, log all query responses to a persistent local store.
  2. When offline, switch out the default network layer for something like https://github.com/relay-tools/relay-local-schema to query the persistent local store instead of the GraphQL endpoint.

Mutations:

  1. Create an immutable persistent log producer for React Native. (perhaps use Kafka?)
  2. Provide optimistic updates as well as log all mutations on device when offline
  3. When the device comes online, connect to a log consumer service and compact mutation logs into GraphQL requests, then somehow trigger fatQueries for the logged mutations so any data not covered by the optimistic updates is applied to state via standard relay.

How do you Facebook folk currently handle offline for native relay apps? such as the Ads Manager? And other GraphQL clients like Facebook for mobile?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions