facebook / facebook/relay

[modern] fatquery migration: how to refetch a connection during a mutation?

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

Description

use case: there exists a dependency between the results of a connection and a mutation but the effect does not consist in just inserting or deleting an edge

With Relay classic it was possible to force the "invalidation" of a connection with the fat query.

```js
fragment Timeline_viewer on Viewer {
timeline @connection(
key: "Timeline_timeline"
) @argumentDefinitions(
first: {
type: Int!
}
otherArgs: {
type: ...
}
) {
edges {
node {
...
}
}
}
}
```

```js
mutation UpdateTimelineSettings(
$input: UpdateTimelineSettingsInput!
) {
updateTimelineSettings(input: $input) {
...
}
}
`;
```

it is not possible to refetch the connection because we do not know if the connection was already fetched once, and we need the same arguments.

```js
export default function(environment: Environment, args) {
commitMutation(
environment,
{
mutation,
variables: ...,
updater() {
// what to do here to force Timeline_timeline to be refetched
}
},
);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.