Changing variables in watchQuery after polling started
See original GitHub issueHi,
so I’m creating an observable with the client.watchQuery
method and watch on it.
It works fine.
But let’s say variables in my query changed.
How to properly handle that? Do I really have to kill the old observable and create a new one which includes the new query?
In other words: How to change variables of a polling ObservableQuery
in runtime?
Idea: Pass in an optional callback that returns the current variables.
I ask, because doing that kill/respawn approach would require a lot of refactoring in my code.
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
This article shows how to fetch GraphQL data in React with the useQuery hook and attach the result to your UI. You'll also...
Read more >Queries – Angular - GraphQL Code Generator
watchQuery method in a very simple way. We simply need to parse our query into a GraphQL document using the gql tag from...
Read more >How to stop polling in angular apollo client? - Stack Overflow
watchQuery <any>({ query: MY_QUERY, variables: { MY_VARIABLEs: ... when the polling query result 'stabilizes' and is not expected to change).
Read more >Queries | Documentation - Glimmer Apollo
The Query Resource uses Apollo's watchQuery for fetching from the network and ... Let's look at the following example where we modify our...
Read more >Apollo Quirks: Polling After Refetching with New Variables
The items in our table change over time, so we're polling our query every five seconds. We also want to give the user...
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
Or yeah, I guess there are also some extra things stored in Redux when you start/stop a query. So it could be less efficient, but we haven’t run into that as a source of problems in our production apps. It’s mostly React renders that are very costly.
Hey guys, thanks for the fast answers. @Poincare your solution works like a charm. So do you want some unit tests or better later when there is a better api for this use case?