Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
Created August 12, 2021 13:26
Show Gist options
  • Save wisaruthk/b81fd219cecf9aa3953f22fe26c2b2c6 to your computer and use it in GitHub Desktop.
Save wisaruthk/b81fd219cecf9aa3953f22fe26c2b2c6 to your computer and use it in GitHub Desktop.
apollo graph cache modify
const onSubmit = (values) => {
console.log(ingredient, values);
cache.modify({
id:cache.identify(ingredient),
fields: {
rcpNutrients(existNts, {readField}){
const index = existNts.findIndex(el => ingdNutrient.id === readField("id",el));
const newNts = [...existNts];
newNts[index] = {
...newNts[index],
val:(values.val === "" ? null:parseFloat(values.val)),
}
return newNts;
}
}
})
handleClose();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment