Why would one do this:
const clientState = {
defaults: {
networkStatus: {
__typename: 'NetworkStatus',
id: 1,
isConnected: false,
},
},
resolvers: {},
};
Over this:
const clientState = {
resolvers: {
Query: {
networkStatus: () => ({
__typename: 'NetworkStatus',
id: 1,
isConnected: false,
}),
},
},
};
The advantages I can see of the latter approach are:
- It's more akin to writing resolvers on the server
- It supports async by simply returning a promise
- It acts as a default because, from my current understanding, the resolver is only called on a cache miss.
I can't see any advantages to using the former defaults
API, but I'm sure there's a reason otherwise it wouldn't exist?