, "" Apollo. AKA, . , Symbol(id).
Apollo, , Symbol(id), Apollo. , Symbol(id), . ?
Apollo .
export function defaultDataIdFromObject(result: any): string | null {
if (result.__typename) {
if (result.id !== undefined) {
return `${result.__typename}:${result.id}`;
}
if (result._id !== undefined) {
return `${result.__typename}:${result._id}`;
}
}
return null;
}
. _id = null, - . null, docs
InMemoryCache , ROOT_QUERY.allPeople.0 , allPeople.
, , defaultDataIdFromObject.
, dataIdFromObject, InMemoryCache ApolloClient. , _id __typename.
const client = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache({
dataIdFromObject: o => (o._id ? `${o.__typename}:${o._id}`: null),
})
});