Guest User

Untitled

a guest
Feb 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. props: ({ ownProps, mutate }) => ({
  2. async renameProject(newName) {
  3. try {
  4. // send form data
  5. await mutate({
  6. variables: {
  7. id: ownProps.id,
  8. name: newName,
  9. },
  10. optimisticResponse: {
  11. renameProject: {
  12. id: -1,
  13. name: newName,
  14. __typename: 'ProjectType',
  15. },
  16. },
  17. update: (store, { data: { renameProject } }) => {
  18. if (renameProject.id === -1) {
  19. // send rename redux action
  20. ownProps.renameProjectAction(newName);
  21. }
  22. },
  23. });
  24. } catch (e) {
  25. handleErrors(e, ownProps.setNotification);
  26.  
  27. // send rename redux action to revert
  28. ownProps.renameProjectAction(ownProps.name);
  29. }
  30. },
  31. }),
Add Comment
Please, Sign In to add comment