In an optimistic response Im getting a missing field error for a field that I think I’m providing.
Here is the error:
Missing field __typename in {
"locationLocation": {
"__typename": "Location",
"id": "cje287moh19io0170ll3h5zg3",
"
writeToStore.js:111
Mutation:
const addToUserLocation = gql`
mutation($userId: ID!, $locationId: ID!) {
addToUserLocation(usersUserId: $userId, locationLocationId: $locationId) {
locationLocation {
id
_usersMeta {
__typename
count
}
}
usersUser {
id
location {
id
}
}
}
}
`;
Function that calls the mutation:
const changeLocation = locationId => {
const userId = userLoggedIn.id;
props
.addToUserLocation({
variables: {
locationId,
userId,
},
optimisticResponse: {
__typename: 'Mutation',
addToUserLocation: {
locationLocation: {
__typename: 'Location',
id: locationId,
_usersMeta: {
__typename: '_QueryMeta',
count: 3000,
},
},
usersUser: {
__typename: 'User',
id: userId,
location: {
__typename: 'Location',
id: locationId,
},
},
},
},
})
.catch(error => {
console.error(error);
});
};
The code appears to be working fine so could this be a bug?