I'm using apollo server.
While mutating data I need to update 2 tables: location
and address
.
End of resolver function:
const locationUpdated = await db.location.updateLocation(user.id, location);
const addressUpdated = await db.address.updateAddress(user.id, location.address);
return { error: null, location: { ...locationUpdated, address: addressUpdated } };
Using GraphQL Playground:
mutation {
updateLocation(
location: {
id: 1
label: "label12"
address: {
city: "city12"
}
}
) {
error
location {
label
address {
city
}
}
}
}
As a result I have new location.label
but old location.address.city
:
{
"data": {
"updateLocation": {
"error": null,
"location": {
"label": "label12",
"address": {
"city": "city11",
}
}
}
}
}
Database is updated correctly. Looks like server uses cache?
question from:
https://stackoverflow.com/questions/65901248/graphql-mutation-for-2-entities-with-parent-child-relation-returns-old-value-for 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…