Refetch does not trigger subscribe
See original GitHub issueThis 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:
- Created 7 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top 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 >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
@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
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. 😉