Skip to content

Support for in-memory and device data #114

@josephsavona

Description

@josephsavona

As mentioned in the introductory blog post, we're exploring ways to extend Relay to represent data from multiple sources. These data sources could be in-memory objects, native device APIs, or a (GraphQL) server.

The goal is to allow a unified programming model for accessing all the information relevant to an application - while also retaining a few important invariants:

  • Components use GraphQL to describe their data dependencies.
  • Given a desired output (e.g. a root container) the framework can statically determine all of the required data inputs (e.g. what to fetch, from where, and in what order).
  • Avoid unnecessary re-computation of intermediate or other derived data.

Proposed API

The proposed API for product developers is the same GraphQL fragments that we use today. Products can define a unified schema of all of their data, and query it as you would expect:

fragment Foo on User {
  name,                     # server field
  drafts(first: 10) {       # client-only field
    edges { node { title } }
  }
}

Some considerations here are how to namespace fields & types to avoid collisions between different data sources, the API for registering non-server types, and the API for updating non-server data.

RFC

We'd appreciate your input about possible use-cases for this feature. Some cases that we have considered are retrieving a list of photos via native devices APIs or storing a list of in-progress drafts/edits.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions