facebook / facebook/relay

[Modern] how to refetch in mutation

Open
#2,213 3 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

in relay modern's config. The rangeBehavior don't have the `refetch` options. what can l do if l want to refetch the whole connection.
```js
const updater = store => {
const payload = store.getRootField('addSingleStorage');
const newEdge = payload.getLinkedRecord('singleStorageEdge');
const organizationProxy = store.get(organizationId);
const conn = ConnectionHandler.getConnection(
organizationProxy,
'Organization_usedStorages',
{
search: null,
inUse: true,
level: 1,
},
);
// how to refetch the connection
ConnectionHandler.insertEdgeBefore(conn, newEdge);
};
const configs = [{
type: 'RANGE_ADD',
parentID: organizationId,
connectionInfo: [{
key: 'Organization_usedStorages',
filters: {
search: null,
inUse: true,
level: 1,
},
// l need to refetch
rangeBehavior: 'prepend',
}],
edgeName: 'singleStorageEdge',
}];
```
Can l do that in updater? How to do that?

note: l don't want to refetch in component by `relay.refetch` in `componentWillReceiveProps`.

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.