Skip to content

Commit

Permalink
update docs for missing field handlers (#4259)
Browse files Browse the repository at this point in the history
Summary:
in response to #4257

Pull Request resolved: #4259

Reviewed By: alunyov

Differential Revision: D44439480

Pulled By: rbalicki2

fbshipit-source-id: a1f29369e39dd32bc4c1f6fc2a5757215b317807
  • Loading branch information
robertf224 authored and facebook-github-bot committed Mar 28, 2023
1 parent f7d62f4 commit 8fcf1fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ const {ROOT_TYPE, Environment} = require('relay-runtime');
const missingFieldHandlers = [
{
handle(field, record, argValues): ?string {
// Make sure to add a handler for the node field
if (
record != null &&
record.getType() === ROOT_TYPE &&
field.name === 'node' &&
argValues.hasOwnProperty('id')
) {
return argValues.id
}
if (
record != null &&
record.getType() === ROOT_TYPE &&
Expand Down
2 changes: 1 addition & 1 deletion website/docs/tutorial/queries-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ You may also notice that this request is made only the first time you hover over
<details>
<summary>Deep dive: Caching and the Relay Store</summary>

In contrast to most other systems, Relay’s caching is not based on queries, but on graph nodes. Relay maintains a local cache of all the nodes it has fetched called the Relay Store. Each node in the Store is identified and retrieved by its ID. If two queries ask for the same information, as identified by node IDs, then the second query will be fulfilled using the cached information retrieved for the first query, and not be fetched.
In contrast to most other systems, Relay’s caching is not based on queries, but on graph nodes. Relay maintains a local cache of all the nodes it has fetched called the Relay Store. Each node in the Store is identified and retrieved by its ID. If two queries ask for the same information, as identified by node IDs, then the second query will be fulfilled using the cached information retrieved for the first query, and not be fetched. Make sure to configure [missing field handlers](/docs/guided-tour/reusing-cached-data/filling-in-missing-data/) to take advantage of this caching behavior.

Relay will garbage-collect nodes from the Store if they aren’t “reachable” from any queries that are used, or have been recently used, by any mounted components.
</details>
Expand Down

0 comments on commit 8fcf1fc

Please sign in to comment.