Using useQuery with pollInterval triggers onCompleted only once
See original GitHub issueIntended outcome:
I would expect the onCompleted
callback to be fired after every poll.
Actual outcome:
onCompleted
is being fired only once. First time the query is made.
How to reproduce the issue:
const { data, stopPolling } = useQuery(QUERY, {
variables: {...},
fetchPolicy: 'network-only',
pollInterval: 1000,
onCompleted: () => console.log('called')
})
Versions
npmPackages: @apollo/react-common: ^3.0.1 => 3.0.1 @apollo/react-hooks: ^3.0.1 => 3.0.1 apollo-cache-inmemory: ^1.3.5 => 1.3.11 apollo-client: ^2.6.4 => 2.6.4 apollo-link: ^1.2.3 => 1.2.4 apollo-link-context: ^1.0.10 => 1.0.10 apollo-link-error: ^1.1.1 => 1.1.2 apollo-link-http: ^1.5.5 => 1.5.7 apollo-link-logger: ^1.2.3 => 1.2.3 apollo-server-koa: ^2.1.0 => 2.2.4 apollo-utilities: ^1.3.2 => 1.3.2 react-apollo: ^2.2.4 => 2.3.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:41
- Comments:39 (6 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
When your component renders, useQuery returns an object from Apollo Client that contains loading , error , and data properties you can use...
Read more >Poll interval option on Apollo client useQuery hook not working
I have a simple forum-like app using apollo server and client(react) and I am trying to periodically update the posts on the main...
Read more >Components - Client (React) - Apollo GraphQL Docs
Optional for the useQuery Hook since the query can be passed in as the first ... onCompleted, (data: TData | {}) => void,...
Read more >urql Documentation - React API
useQuery ; query, string | DocumentNode, The query to be executed. Accepts as a plain string query or GraphQL DocumentNode. ; variables ?object,...
Read more >How to use the react-apollo.useLazyQuery function in ... - Snyk
useLazyQuery examples, based on popular ways it is used in public projects. ... to run this effect only once, otherwise we might end...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Setting
notifyOnNetworkStatusChange
totrue
solved the issue in my case.Also, @dominik-myszkowski , setting
fetchPolicy: 'network-only'
only triggers theonCompleted
once. I can only get it working by settingnotifyOnNetworkStatusChange: true