我的readQuery返回了一个field not found
错误,即使该字段似乎存在于缓存中。
查询
const GETIMSFROMCACHE_QUERY = gql`
query getIMsFromCache($fromID: String!){
instant_message(fromID:$fromID){
id,
fromID,
toID,
msgText
}
} `;
缓存解析器
client.cache.cacheResolvers = {
Query: {
instant_message: (_, args) => toIdValue(client.dataIdFromObject({
__typename: 'instant_message',
id: args.id
})),
},
};
更新中的READQUERY调用
let instant_message = cache.readQuery({ query: GETIMSFROMCACHE_QUERY, variables: {"fromID": fromID} });
错误
Error: Can't find field instant_message({"fromID":"ayqNLcA7c6r8vip3i"}) on object (ROOT_QUERY) {
"getMyUserData({\"id\":\"ayqNLcA7c6r8vip3i\"})": [
{
"type": "id",
"generated": false,
"id": "MyUserData:ayqNLcA7c6r8vip3i",
"typename": "MyUserData"
}
],
"getMyUserData({\"id\":\"9W95z8A7Y6i34buk7\"})": [
{
"type": "id",
"generated": false,
"id": "MyUserData:9W95z8A7Y6i34buk7",
"typename": "MyUserData"
}
],
"Appts({\"originatingUserID\":\"ayqNLcA7c6r8vip3i\"})": [],
"instant_message({\"fromID\":\"ayqNLcA7c6r8vip3i\",\"toID\":\"9W95z8A7Y6i34buk7\"})": [
{
"type": "id",
"generated": false,
"id": "instant_message:126",
"typename": "instant_message"
},
{
"type": "id",
"generated": false,
"id": "instant_message:127",
"typename": "instant_message"
},
{
"type": "id",
"generated": false,
"id": "instant_message:128",
"typename": "instant_message"
}
]
}.
查看错误消息,ROOT_QUERY对象上似乎存在一个具有目标用户id的instant_message
对象,但我得到了这个错误。
我怎样才能纠正这个错误呢?
提前感谢所有人的任何信息。
https://stackoverflow.com/questions/50779328
复制相似问题