You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
variables with nested items are overriden when fetchMore is performed. I am not sure whether this issue has already been reported or not but I couldn't find it anywhere in repo so far.
for example
const{ data, fetchMore }=useQuery(MY_QUERY,{variables: {parentVariable: {a: "some_value",},},});// in fetch moreasyncfunctionfetchMoreItems(){awaitfetchMore({variables: {parentVariable: {// here instead of `a` some other value is passed. // so new value of parentVariable will be // { b : "some_value" } rather than { a: "some_value", b: "some_value" }b: "some_value"}},// concat items, can be ignoredupdateQuery: (previousResult,{ fetchMoreResult })=>{constnewEdges=fetchMoreResult?.people??[];constoldEdges=previousResult?.people??[];return{people: [...oldEdges, ...newEdges],};},});}}
Although the doc says merged but docs don't really say that nested objects will be overriden with new value.
This might be intended and does make sense but should be documented
Thats a good callout about the docs. The merge that happens is a shallow merge so what you're seeing is expected. I've opened #12080 to make it a bit clearer in the docs that variable merging is a shallow merge.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.
Issue Description
variables with nested items are overriden when
fetchMore
is performed. I am not sure whether this issue has already been reported or not but I couldn't find it anywhere in repo so far.for example
Although the doc says merged but docs don't really say that nested objects will be overriden with new value.
This might be intended and does make sense but should be documented
Link to Reproduction
https://codesandbox.io/p/devbox/practical-wozniak-d6mxd4?workspaceId=b0cc520f-8431-4414-9657-24f9bb60a21b
Reproduction Steps
No response
@apollo/client
version3.5.6
The text was updated successfully, but these errors were encountered: