Created
August 12, 2021 13:26
-
-
Save wisaruthk/b81fd219cecf9aa3953f22fe26c2b2c6 to your computer and use it in GitHub Desktop.
apollo graph cache modify
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
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