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.

Refetch does not trigger subscribe

See original GitHub issue

This is a question/possible bug about the refetch method documented here.

I noticed that refetch returns a promise that resolves the new data. However, I had expected that a subscription on the original query would be triggered when refetch is called. This is not the case, eg:

ngOnInit() {
  this.query = this.apollo.watchQuery({query: TestQuery});
  this.query.subscribe(({data}) => {
    console.log(data);
  });
}

refetch() {
  this.query.refetch();
}

I would expect the subscribe callback to be triggered again after refetch is executed. Could someone clarify why this does not happen?

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
blissicommented, Mar 30, 2018

@kamilkisiela I debugged it and I think I found the issue - it’s in Apollo Client and not in Apollo Angular. I created a bug over there: https://github.com/apollographql/apollo-client/issues/3235

1reaction
Eraldocommented, Nov 29, 2017

I also have the same problem. How about reopening the issue?

(also when using the code snippet from @conor-mac-aoidh) The angular apollo docs don’t really explain refetch. They only mention the method without it’s workings as far as I can tell at least. 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refetch does not trigger subscribe · Issue #176 - GitHub
This is a question/possible bug about the refetch method documented here. I noticed that refetch returns a promise that resolves the new data....
Read more >
Refetching queries in Apollo Client - Apollo GraphQL Docs
The client.refetchQueries method collects the TResult results returned by onQueryUpdated , defaulting to TResult = Promise<ApolloQueryResult<any>> if ...
Read more >
How can I refetch() my Query only when new subscription data ...
I have time series data being added to a database triggering onChangedWeatherIntervals subscription which returns summary info about the new ...
Read more >
Queries - Redux Toolkit
Automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached ...
Read more >
useQuery | TanStack Query Docs
useQuery · Optional · Defaults to true · If set to true , the query will refetch on window focus if the data...
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