OV
Size: a a a
OV
I
OV
OV
A
const configs = [
{
type: 'RANGE_ADD',
parentID: 'client:root',
connectionInfo: [
{
key: 'tags',
rangeBehavior: 'append',
},
],
edgeName: 'tag',
},
];
const tagMutation = {
createTag: (environment, input) => {
return new Promise((resolve, reject) => {
commitMutation(environment, {
mutation: createTagMutation,
variables: { input },
onCompleted(response, errors) {
console.log('onCompleted', response);
if (errors) {
reject(errors[0]);
} else {
resolve(response.createTag.tag);
}
},
onError: reject,
updater: store => {
console.log('store', store);
},
configs,
});
});
},
};
port default createFragmentContainer(Вот что получилось, но ничего не обновляется
withStyles(styles)(CreateTag),
graphql`
fragment CreateTagAdmin on Query {
tags {
id
slug
title
}
me {
id
firstName
lastName
avatarPreview
}
}
`,
);
OV
OV
OV
A
OV
A
updater: Function used to update the local in-memory store based on the real server response from the mutation. If updater is not provided, by default, Relay will know to automatically update the fields on the records referenced in the mutation response; however, you should pass an updater if you need to make more complicated updates than just updating fields (e.g. deleting records or adding items to collections).
OV
OV
OV
A
A
A
updater: (store: RecordSourceSelectorProxy) => {
const payload = store.getRootField('createTag');
const tag = payload.getLinkedRecord('tag');
const root = store.getRoot();
const rootTags = root.getLinkedRecords('tags') || [];
const newRootTags = [tag, ...rootTags];
root.setLinkedRecords(newRootTags, 'tags');
},
Б