My understanding is when you make a query that uses variables, that query is stringified, along with the variables.
For example, say . you have a query that gets a list of items. The query takes in a “sortBy” variable that can be a string (“createddAt”, “priority”) and the backend will sort the query appropriately.
Now say you have a form for adding new items to this list. You use a mutation. You can then use a few different ways to update the list with the new item. You can use refetch queries or the
With the update field you’ll likely use writeQuery/readQuery.
The issue here is when you are telling apollo which query to update, it needs to know the exact variables that were used.
The only way I’ve found to make it work is to pass the variables down into my form as a props, but this isn’t always feasible/ideal.
How are others handling this problem in react? Storing variables in redux? In context?