facebook / facebook/relay

Allow to change global default value for `fetchPolicy`

Open
#4,108 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Currently, we cannot set a global default value for `fetchPolicy`.

The code in https://github.com/facebook/relay/blob/f96771be3eece437fdede48bc8c9ddfa0253d4e2/packages/react-relay/relay-hooks/loadQuery.js#L91 explicitly uses either the operation configuration or defaults to `store-or-network`.

It'd be ideal to be able to update the environment (or something else) such that we could globally change what's the default value for `fetchPolicy` as we do not feel `store-or-network` is adequate as a default in every application - in our case, `store-and-network` would make the most sense.

Contributor guide

Open the contributing guide

Research direction

Start in packages/react-relay/relay-hooks/loadQuery.js at the operation-configuration handling around line 91, and trace how the environment is passed into loadQuery. Determine where a configurable global fetchPolicy could be selected instead of the store-or-network fallback. Done means applications can set a global default while an operation-specific fetchPolicy still takes precedence.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.