My readQuery is returning a field not found
error, even though it seems like the field is present in the cache.
QUERY
const GETIMSFROMCACHE_QUERY = gql`
query getIMsFromCache($fromID: String!){
instant_message(fromID:$fromID){
id,
fromID,
toID,
msgText
}
} `;
CACHE RESOLVER
client.cache.cacheResolvers = {
Query: {
instant_message: (_, args) => toIdValue(client.dataIdFromObject({
__typename: 'instant_message',
id: args.id
})),
},
};
READQUERY CALL, IN UPDATE
let instant_message = cache.readQuery({ query: GETIMSFROMCACHE_QUERY, variables: {"fromID": fromID} });
ERROR
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"
}
]
}.
Looking at the error message, there seems to be a instant_message
object present on the ROOT_QUERY object with the target user id, but I'm getting this error.
How can I correct this?
Thanks in advance to all for any info.