为什么要这么做:
const stateLink = withClientState({
cache,
resolvers: {
Mutation: {
updateNetworkStatus: (_, { isConnected }, { cache }) => {
const data = {
networkStatus: {
__typename: 'NetworkStatus',
id: 1,
isConnected
},
};
cache.writeData({ data }); // <--
return null; // <--
},
},
}
});
对此:
const stateLink = withClientState({
cache,
resolvers: {
Mutation: {
updateNetworkStatus: (_, { isConnected }, { cache }) => {
const data = {
networkStatus: {
__typename: 'NetworkStatus',
id: 1,
isConnected
},
};
return data; // <--
},
},
}
});