Apollo-client: Bug - use query is repeatly called when init component

Created on 29 May 2020  路  5Comments  路  Source: apollographql/apollo-client

I've attached here the bug I am using

 "@apollo/client": "^3.0.0-beta.50"

Screenshot 2020-05-29 at 14 49 18
Screenshot 2020-05-29 at 14 50 49

Most helpful comment

the issue is when you setup

defaultOptions: {
        watchQuery: {
            fetchPolicy: 'network-only',
        },
    },

the version . "@apollo/client": "^3.0.0-beta.50" doesn't trigger onCompleted function anymore..

ANY Idea was is BROKEN?

is breaking all my project can Apollo CLIENT TEAM FIX THOSE ISSUES ?

All 5 comments

I am also running into this, using 3.0.0-beta.53. It happens immediately when using useQuery, but also happens once the query function has been called when using useLazyQuery. I've gone back to 3.0.0-beta.45 for now which doesn't seem to have the issue.

I just notice the issue.. the loader inside the component does the reloading all the time... very weird why I鈥檓 not sure what鈥檚 the reason

the issue is when you setup

defaultOptions: {
        watchQuery: {
            fetchPolicy: 'network-only',
        },
    },

the version . "@apollo/client": "^3.0.0-beta.50" doesn't trigger onCompleted function anymore..

ANY Idea was is BROKEN?

is breaking all my project can Apollo CLIENT TEAM FIX THOSE ISSUES ?

I also get this with "network-only" and "no-cache" fetch policy and onCompleted not being called.
Works as expected with the default "cache-first" fetch policy.

version:

 "@apollo/client": "^3.0.0-rc.0"

After some scouring of open issues, I believe what I was experiencing here is a duplicate of #6301 - the suggested fix there of memoizing the onComplete and onError callbacks has stopped my query requests from looping. The reproduction there is also accurate for my use case so I suggest this issue can be closed in favour of that one.

Was this page helpful?
0 / 5 - 0 ratings