Skip to content

Instantly share code, notes, and snippets.

@pkellner
Created October 14, 2020 21:34
Show Gist options
  • Save pkellner/2d8b4c6527bf1f6b38106ccac9ca574d to your computer and use it in GitHub Desktop.
Save pkellner/2d8b4c6527bf1f6b38106ccac9ca574d to your computer and use it in GitHub Desktop.
Button Click To Sort GraphQL Cache
<Button color="warning" onClick={() => {
const { speakers } = apolloClient.cache.readQuery({ query: GET_SPEAKERS });
apolloClient.cache.writeQuery({
query: GET_SPEAKERS,
data: {
speakers: {
datalist: [...speakers.datalist].sort((a,b) => a.id - b.id)
},
},
});
}}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment