useQuery onCompleted
is called with old data when query makes use of @export
directive
#10452
Labels
onCompleted
is called with old data when query makes use of @export
directive
#10452
Issue Description
If a query is ever re-fetched (i.e. from a variable change), and the query makes use of the
@export
directive, then theonCompleted
callback will incorrectly be called twice. First with the previous query result, and then with the new query result. Note that this only happens when the query is re-run. The very first time the query runs,onCompleted
is only called once (as expected).Link to Reproduction
https://codesandbox.io/s/apollo-oncompleted-issue-q5e9ss?file=/src/App.jsx
Reproduction Steps
onCompleted
is called once with the data forid: 1
. This is correct so far.id
to2
onCompleted
is called two additional times. First with the old data forid: 1
, and then again with the new data forid: 2
.Also note that does not happen if there is no
@export
directive in the query. In that case, changingid
only results in one additionalonCompleted
call, the one with the new data.The text was updated successfully, but these errors were encountered: