proxy.readQuery throws an error on not executed queries
See original GitHub issueI am having a structure which looks like the following:
type Person {
id: string
friends: [Friend]
addresses: [Address]
}
At one point in time I am fetching one persons addresses, which is being cached in the store while using the id field.
At a later point in time, I am doing a mutation on the object and add a new friend. Please note, that at this point in time the user did not request to fetch the list of friends for now. In order to keep the friends list up to date, I am still doing a proxy.readQuery
operation on the query which is responsible for fetching all friends of a user and pushing the new friend into it. For now I don’t keep track if the user already executed this query at some point in the past. If the user did so, everything is alright. If however he did not fetch the list of friends and I am trying to execute the proxy.readQuery
on that query, I will get an exception like that:
Error: Can't find field PersonFriends on object (Person:UGVyc29uOjE=) {
"id": "UGVyc29uOjE=",
"Viewer_addresses": {
"type": "id",
"id": "$Person:UGVyc29uOjE=.Viewer_addresses",
"generated": true
},
"__typename": "Person"
}
I would like to prevent catching this exception. Is there any way from Apollo’s side to know if a certain query was executed in the past and don’t execute the proxy.readQuery
in that case?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
See also issue #2007
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client!