我的 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 CALL,更新中
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 对象上似乎存在一个instant_message
具有目标用户 ID 的对象,但我收到此错误。
我该如何纠正?
提前感谢所有人提供的任何信息。