javascript - How do I handle deletes in react-apollo -


i have mutation like

mutation deleterecord($id: id) {     deleterecord(id: $id) {         id     } } 

and in location have list of elements.

is there better return server, , how should update list?

more generally, best practice handling deletes in apollo/graphql?

i not sure good practise style here how handle deletion of item in react-apollo updatequeries:

import { graphql, compose } 'react-apollo'; import gql 'graphql-tag'; import update 'react-addons-update'; import _ 'underscore';   const scenecollectionsquery = gql ` query scenecollections {   myscenes: selectedscenes (excludeowner: false, first: 24) {     edges {       node {         ...scenecollectionscene       }     }   } }`;   const deletescenemutation = gql ` mutation deletescene($sceneid: string!) {   deletescene(sceneid: $sceneid) {     ok     scene {       id       active     }   } }`;  const scenemodifierwithstateanddata = compose(   ...,   graphql(deletescenemutation, {     props: ({ mutate }) => ({       deletescene: (sceneid) => mutate({         variables: { sceneid },         updatequeries: {           scenecollections: (prev, { mutationresult }) => {             const mysceneslist = prev.myscenes.edges.map((item) => item.node);             const deleteindex = _.findindex(mysceneslist, (item) => item.id === sceneid);             if (deleteindex < 0) {               return prev;             }             return update(prev, {               myscenes: {                 edges: {                   $splice: [[deleteindex, 1]]                 }               }             });           }         }       })     })   }) )(scenemodifierwithstate); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -