Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise support in the resolve() function #27

Closed
rricard opened this issue Jul 6, 2015 · 3 comments
Closed

Promise support in the resolve() function #27

rricard opened this issue Jul 6, 2015 · 3 comments

Comments

@rricard
Copy link

rricard commented Jul 6, 2015

I started to work on this graphql implementation in order to integrate it at least partially in our systems. We would like to stay very close to this implementation as much as we can as it may become the first community-supported implementation.

A feature we would need is the ability to wait Promise results when resolving. It doesn't seem that the current implementation support it.

I would like to discuss with you if you are open to support the addition of Promise responses. In this case, I can handle the Pull-request.

So if I were to implement this, I would do it like this:

  1. Write tests with promises (either mix promises and direct calls in the current test schemas or create a completely new test schema with Promises)
  2. When resolving the query, wait for the promises when a resolve function returns a Promise. At the end, this doesn't need any API change since the result goes to a final promise when querying anyway.

We can discuss all of that if you wish of course!

@freiksenet
Copy link
Contributor

It should be possible to return promises in resolve. Can you provide code samples on what doesn't work?

resolve checks that if something is a promise with this utility. So your promise should be an object with then method.

@rricard
Copy link
Author

rricard commented Jul 6, 2015

Oh great. Didn't got it either from the code or the examples but I'll
definitely take a look. I could write some tests on this. You can close
that, thanks!

On Mon, Jul 6, 2015, 13:15 Mikhail Novikov [email protected] wrote:

It should be possible to return promises in resolve. Can you provide code
samples on what doesn't work?


Reply to this email directly or view it on GitHub
#27 (comment).

@leebyron
Copy link
Contributor

leebyron commented Jul 7, 2015

Yep! we support returning Promises or Arrays of Promises.

@leebyron leebyron closed this as completed Jul 7, 2015
chrisbolin added a commit to chrisbolin/graphql-js that referenced this issue Mar 22, 2016
In response to graphql#27 and SO questions. I don't believe there is "official" documentation (besides in issues and tests) of Promise support in the resolve function. Totally willing to be wrong :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants