question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing variables in watchQuery after polling started

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
stubailocommented, Jul 21, 2016

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.

1reaction
timsuchanekcommented, Jun 8, 2016

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found