Why doesn't .query() return a Promise?
See original GitHub issueI’ve asked this here https://github.com/apollographql/apollo-client/issues/2561#event-1343477916 and I was told that apollo-client itself returns a promise on .query()
- why doesn’t apollo-angular do the same as apollo-client?
Here’s the question I asked in the apollo-client repo:
Just wanted to ask for the reasen why .query() does not return a Promise
I always end up calling .toPromise() because I don’t want to unsubscribe something that is executed once anyway.
And if there’s a good reason for it, does this mean, calling toPromise() is bad practice?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Problem with promises and mysql query return value
You can just return the promise itself. function query(query:string):Promise<string> { var sendrequest = (query:string):Promise<string> ...
Read more >Why doesn't .query() return a Promise? #2561
I always end up calling .toPromise() because I don't want to unsubscribe something that is executed once anyway. And if there's a good...
Read more >Promise.all() - JavaScript - MDN Web Docs
The Promise.all() method takes an iterable of promises as input and returns a single Promise . This returned promise fulfills when all of ......
Read more >Mongoose v6.8.1: Promises
Mongoose queries are not promises. They have a .then() function for co and async/await as a convenience. If you need a fully-fledged promise,...
Read more >Sync, async, and promises | Cloud Functions for Firebase
When you return a JavaScript promise to a function, that function keeps running until the promise is resolved or rejected. To indicate that...
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
It’s angular integration, it means there are Observable that can be chained. The whole ecosystem is built on Observables instead of Promises.
Instead of calling
.subscribe()
you can just call.toPromise()
and then it works as expected.