问题描述: 在使用Apollo InMemoryCache时,出现了无法找到keyfields的错误。
解决方法:
npm list apollo-cache-inmemory
import { InMemoryCache } from 'apollo-cache-inmemory';
const cache = new InMemoryCache();
const client = new ApolloClient({
cache: cache,
// other configurations...
});
const cache = new InMemoryCache({
typePolicies: {
Query: {
fields: {
// define keyFields for specific fields in Query
fieldName: {
keyFields: ['id', 'name']
},
// define keyFields for all other fields in Query
'*': {
keyFields: ['id']
}
}
}
}
});
npm uninstall apollo-cache-inmemory
npm install apollo-cache-inmemory
如果问题仍然存在,请参考Apollo文档、GitHub仓库或提问相关社区获取更多帮助。