Last active
November 24, 2021 18:35
-
-
Save cevr/9ab1fe498ba8383d13fab8c7aaca26c8 to your computer and use it in GitHub Desktop.
Cache update after mutation with writeFragment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createCaseFromEvent(result, variables, cache) { | |
const readEvent = () => | |
cache.readFragment( | |
gql` | |
fragment _ on CaseManagementEvent { | |
id | |
cases { | |
id | |
status | |
} | |
} | |
`, | |
{ | |
id: variables.eventId | |
} | |
); | |
console.log(readEvent()); | |
cache.writeFragment( | |
gql` | |
fragment _ on CaseManagementEvent { | |
id | |
} | |
`, | |
{ | |
id: variables.eventId, | |
cases: [result.createCaseFromEvent as CaseManagementEventCase] | |
}, | |
{ | |
id: variables.eventId | |
} | |
); | |
console.log(readEvent()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment