Skip to content

Instantly share code, notes, and snippets.

@seandearnaley
Created March 5, 2020 02:23
Show Gist options
  • Save seandearnaley/15f9424957be030e51c24b341a3eb100 to your computer and use it in GitHub Desktop.
Save seandearnaley/15f9424957be030e51c24b341a3eb100 to your computer and use it in GitHub Desktop.
Remove Card Snippet for Connection
cache.modify(`Category:${categoryId}`, {
cards(cards: Reference, { readField }) {
const edges = readField<CardEdgeWithReference[]>('edges', cards).filter(
edge => edge.node.__ref !== `Card:${cardId}`,
);
let { totalCount } = readField<PageInfo>('pageInfo', cards);
const pageInfo = buildPageInfo<Edge<Card>>(edges, --totalCount, 'Card'); // rebuild pageinfo
return {
edges,
pageInfo,
};
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment