facebook / facebook/relay

Suggestion: add Optional varieties to useQuery

Open
#2,936 12 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I'm not sure if this is 'supported/intended' behaviour, but QueryRenderer allows you to pass an undefined query prop. If no query prop is supplied, then no data is fetched.

This is useful for some components which only need to fetch data under certain circumstances.

The new experimental hooks have no way of omitting the first argument.

I suggest introducing optional varieties of the use LazyLoad / Preloaded Queries that allow the conditional fetching of data.

Contributor guide

Open the contributing guide

Research direction

Start by comparing QueryRenderer's handling of an omitted query prop with the experimental use LazyLoad and Preloaded Queries hooks. Determine the intended API for optional query arguments and how conditional fetching should behave. Done means the hooks support omitted queries in the proposed optional varieties while preserving existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, 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.