Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- props: ({ ownProps, mutate }) => ({
- async renameProject(newName) {
- try {
- // send form data
- await mutate({
- variables: {
- id: ownProps.id,
- name: newName,
- },
- optimisticResponse: {
- renameProject: {
- id: -1,
- name: newName,
- __typename: 'ProjectType',
- },
- },
- update: (store, { data: { renameProject } }) => {
- if (renameProject.id === -1) {
- // send rename redux action
- ownProps.renameProjectAction(newName);
- }
- },
- });
- } catch (e) {
- handleErrors(e, ownProps.setNotification);
- // send rename redux action to revert
- ownProps.renameProjectAction(ownProps.name);
- }
- },
- }),
Add Comment
Please, Sign In to add comment