Intended outcome:
I'm attempting to use partialRefetch to refetch a partial array item that was add as a result of an "add" mutation.
Actual outcome:
Instead of an empty data object, the returned array is simply missing the partial objects.
How to reproduce the issue:
Client: https://codesandbox.io/s/apollo-empty-data-bug-client-ycntj
Server: https://codesandbox.io/s/apollo-empty-data-bug-server-8ncuk
Line 43 can be uncommented to see the behavior when there is no partial data (i.e., the title is returned by the mutation). When that line is commented, the missing title causes the workspaces' todos to come back as partial data and even though partialRefetch is specified, there is no refetch.
Versions
@apollo/client: 3.0.0-beta.1
@migueloller This appears to be working with @apollo/[email protected]. If you still think this is an issue, let us know. Thanks!
@hwillson, it is not working for @apollo/[email protected]. A look at the reproduction sandboxes shows that while data is coming back as partial, there's no refetch happening. One could argue this is even worse since now the shape of the data returned does not follow the GraphQL schema.
Note that returnPartialData is not set, which according to the documentation defaults to false, so one would expect there to be no data, then a refetch, then fetched data. So neither returnPartialData or partialRefetch are working as expected in @apollo/[email protected].
Ahh, I misinterpreted your explanation @migueloller, sorry about that! Re-opening.
@migueloller This should now be fixed if you update to @apollo/[email protected], judging from your reproduction (thanks for that!).
@migueloller @apollo/[email protected] appears to be working properly with your reproduction, so I'll close this off. Let us know otherwise. Thanks!
@benjamn and @hwillson, it seems to be working now!
I do have a question, though. When refetching, data is set to undefined while loading is true. Would it make sense to keep data as the last fetched value while the refetch is happening?
More specifically, I expected the behavior to be that of refetch where loading doesn't change and networkStatus goes to 4 for "refetching". While the data is being fetched, the old data is untouched.
Most helpful comment
@benjamn and @hwillson, it seems to be working now!
I do have a question, though. When refetching,
datais set toundefinedwhileloadingistrue. Would it make sense to keepdataas the last fetched value while the refetch is happening?More specifically, I expected the behavior to be that of
refetchwhereloadingdoesn't change andnetworkStatusgoes to4for "refetching". While the data is being fetched, the old data is untouched.