How do you pass additional args to the optimistic update functions? #2106
-
Hopefully someone could point out if I'm doing something wrong here. Basically the optimisticVariables are not appearing in the function, only the variables specified in the mutation. Referencing: https://formidable.com/open-source/urql/docs/graphcache/cache-updates/#variables-for-optimistic-updates
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the docs aren't precise enough here and I'll have to fix them up. Apologies! 🙏 Basically, variables and arguments are different here. You define your variables, e.g. That means that during optimistic mutations however, were able to send more variables because they haven't been filtered for the API yet. Hence you'll see more variables that you've passed, but not more arguments. The variables will still be filtered later however To then access the raw variables, you can use This is an escape hatch because it's obviously a raw object and it will happen to be exactly what you've passed, but not safely filtered. |
Beta Was this translation helpful? Give feedback.
I think the docs aren't precise enough here and I'll have to fix them up. Apologies! 🙏
Basically, variables and arguments are different here. You define your variables, e.g.
$var
and your field args, e.g.input: $var
. Your field will only seeinput: ...
since it takes a subset of the variables. GraphQL basically allows Graphcache to also filter variables before they're sent to the API.That means that during optimistic mutations however, were able to send more variables because they haven't been filtered for the API yet. Hence you'll see more variables that you've passed, but not more arguments. The variables will still be filtered later however
To then access the raw variables, you can use