I have a screen where I run a query and render some items based on the results:
query getMyFavoritePlaces($myID: String) {
favorite_place(where: { user_id: { _eq: $myID } }) {
id
location
label
user{
id
}
user_id
}
}
const { data, error } = useGetMyFavoritePlacesQuery({ variables: { myID: profile.id }});
{
data && (
<FlatList
data={data.favorite_place}
renderItem={({ item }) => <FavoriteLocationEntry place={item} />}
keyExtractor={(item) => item.id.toString()} />
)
}
When I run this mutation by clicking on any of the items from the flatlets:
mutation RemoveFavoriteLocation($id: Int!) {
delete_favorite_place_by_pk(id: $id) {
id
location
label
user{
favorite_places {
id
location
label
}
}
user_id
}
}
The object gets deleted successfully and the UI is also updated. However, I get a warning that
Cache data may be lost when replacing the favourite_place field of a Query object. To address this problem define a custom merge function for the Query.favorite_place field, so InMemoryCache can safely merge these objects: { ... }
The values shown here are the ids. I am already returning ids in both, the query and mutation. How can I fix it then?
It might not be possible to run the favourite_place
query itself within the mutation.