03
Responses are trees. The store is a graph.
When a response arrives, Relay walks it and writes every object with an
id into a flat map of records keyed by that id. Nested objects become references. This is the live store of this tab, drawn directly from environment.getStore().getSource().Fetching with Relay…
- why it mattersOne record per entity means one source of truth. Rename a user and every post, comment and avatar that references them is correct, with no manual cache syncing.
- why it mattersQueries with different shapes share records. The second query adds fields to an existing
Userrather than creating a stale copy. - why it mattersConnections are records too (toggle them on). That's how Relay can append a page of edges or insert a new comment without refetching the list.