http://dev.apollodata.com/react/mutations.html
I am trying out with optimisticResponse
, but i am confused... and couldn't get it working on my local.
My questions are:
optimisticResponse
update the props
and hence the re-render? how important is __typename: 'Mutation'
can you leave it?updateQueries
is for new record appear? is this function trigger automatically or you need to invoke it?is there any full example of out there which include the apollo server side?
Solution found:
const networkInterface = createNetworkInterface('http://localhost:8080/graphql');
this.client = new ApolloClient({
networkInterface,
dataIdFromObject: r => r.id
}
);
dataIdFromObject is the one thing i am missing during the Apolloclient initiation
dataIdFromObject (Object) => string
A function that returns a object identifier given a particular result object.
it will give unique ID for all result object.