facebook / facebook/relay

Relay Refetch container refetch method does not have prev Fragment variables

Open
#2,454 2 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I am using refetch container to set different set of variable, but overriding only subset of all the variables.
fragmentVariables always have initial value passed from QueryRenderer

```
setRelayVariables = (variables, stateVariables) => {
const refetchVariables = fragmentVariables => {
// fragment variables always have initial variables passed from QueryRenderer
return ({
...fragmentVariables,
...variables,
});
};
if (stateVariables) {
this.setState(stateVariables);
}
this.props.relay.refetch(refetchVariables, null, (error) => {
if (error) {
console.log('ERROR while refetching', error);
}
if (stateVariables && stateVariables.isLoading) {
this.setState({
isLoading: false,
});
}
});
}
```

As per the documentation prev Variables should be accessible in refetchVariables function.

**Or, a function that receives the previous set of variables used to query the data, and returns a new set of variables to pass to the refetchQuery when fetching it from the server.**

Did anyone face similar issue ?

Contributor guide

Open the contributing guide

Research direction

Start at the refetch container's refetch entry point and inspect how the refetchVariables callback is invoked relative to the QueryRenderer variables. Compare that behavior with the documented previous-variable contract in the issue. Done means the callback receives the previous variables when overriding only a subset; verify the behavior with the relevant refetch-container test if one is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.