apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

fetchPolicy cache-and-network makes loading get updates on refetch

Open EvertEt opened this issue 2 years ago • 5 comments

Intended outcome: loading should not be updated when calling refetch. Even when using fetchPolicy cache-and-network

Actual outcome: loading became true again when calling refetch. This is the behaviour without a specified fetchPolicy. (And no notifyOnNetworkStatusChange specified)

How to reproduce the issue: https://codesandbox.io/s/elastic-dan-r056e3?file=/src/index.jsx:461-498 You can comment the fetchPolicy line and see loading is not shown when refetching.

Versions See sandbox, started from sandbox template.

EvertEt avatar Oct 07 '22 12:10 EvertEt

@EvertEt 👋 this problem might be covered in this issue https://github.com/apollographql/apollo-client/issues/10105, could you check it out and let us know?

jpvajda avatar Oct 12 '22 23:10 jpvajda

@jpvajda To me it seems to be a different issue but I am not very experienced with apollo yet.

EvertEt avatar Oct 13 '22 07:10 EvertEt

#10105 is closed but the problem persists in last version

EvertEt avatar Dec 16 '22 16:12 EvertEt

I think current loading behaviour is ideal as we are refetching latest data.

jeel-toddleapp avatar Jan 04 '24 06:01 jeel-toddleapp

I am seeing the same issue in our app. With no data changed, the component still got updated twice when calling refretch. This is only happening with the cache-and-network fetchPolicy. We are using the Apollo client 3.7.16. The latest 3.9.8 also has this problem.

hankwz avatar Mar 22 '24 18:03 hankwz