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
Intial refactoring to work over observables instead of promises #502
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Hi @leebyron can you please review this? |
While I'm excited to support fields that return Observable values, I don't support this approach. First, we shouldn't take a dependency on a large library like rxjs, either directly or as a peer dependency. Second, we should minimize the set of changes to the core executor. Third, we still need to support Promises/Thenable as the most common use case. |
I'm in favor of continued experimentation in this area though. This is closely aligned with some other earlier experiments to add @LiVe to GraphQL. |
Hi @leebyron thanks for the quick response :) |
Another question is what we actually want to see from a reactive GraphQL executor. We probably do not want to re-execute fields that are likely to have not changed and the output should be a series of diffs to send over the network rather than a series of whole values |
hehe, seems that we are aligned, just released today rxjs-diff-operator which is exactly for that purpose. the update logic is same as the old one, |
hi @leebyron, eventually i decided to create a seperated npm (graphql-rxjs) package for this for the moment being. |
Really excited to see where this goes. I think observables in the resolver return can be a neat way to do subscriptions as well. |
hi @leebyron, i have a server side example (getting graphiql with subscription over observables) so, if you want to take a look, if you want to really play with it, just clone it (note this is rxjs-subscriptions branch), and then npm install & npm start. Other then that, i'm not sure what are you against in here, also, once this is resolved i would be happy to work on the @defer/@live/@stream directives as well as with observables it's very easy to implement. |
@leebyron can you please reply? |
Hey @DxCx, sorry for the delayed response. Since this library primarily serves to be a production node server and reference implementation of the spec, I don't think it's the appropriate place for this kind of experimentation for fear that other implementations would see it as part of the direction of GraphQL, and this is not yet what we'd like to do. Notably - it's important that the execution code align to the spec to be a good reference implementation. I do think it's a great idea to experiment with observable-based resolvers, it's an exciting idea that deserves to be explored - but I think that exploration deserves it's own repository which can move quickly and experiment with different ideas without worrying about breaking core users. |
I'm going to close this PR since we don't want to pursue this in this repository - I'm looking forward to seeing your work as a separate package. |
hey @leebyron i mean, i want to introduce some execute function ( |
Hey @leebyron, Now that AsyncIterator has reached Stage 4, I'd love to hear your thoughts on @DxCx 's proposal above to add AsyncIterator support to the execute function. The ability to return multiple results from the execute function would be a huge step forward for live queries. Thanks! |
A live query would need a separate core executor. It might use some parts
of the algorithm which are the same, however the live executor will have
different concerns, so we should not convert the existing executor to be a
live executor.
I agree that for a live executor, AsyncIterators will be an important
implementation detail, however I’d recommend accepting either AIs or
Observables from resolver functions
…On Sat, Feb 17, 2018 at 11:18 AM Sat Mandir S. Khalsa < ***@***.***> wrote:
Hey @leebyron <https://github.com/leebyron>,
Now that AsyncIterator has reached Stage 4
<tc39/proposals@a41dccc>,
I'd love to hear your thoughts on @DxCx <https://github.com/dxcx> 's
proposal above to add AsyncIterator support to the execute function. The
ability to return multiple results from the execute function would be a
huge step forward for live queries. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#502 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADD0pIZEQDOK5Xm8hG8HlbkHQJEbPBfks5tVvu8gaJpZM4KFbHW>
.
|
@leebyron That makes sense. I believe that @DxCx 's graphql-rxjs takes this approach, with a separate Would you consider a PR for adding reactive executors to the library at this time? Thanks again! |
At this point I think it makes sense for add on libraries to work out
different approaches. If one approach becomes robust to all use cases we
could consider merging it into this library
…On Sat, Feb 17, 2018 at 10:18 AM Sat Mandir S. Khalsa < ***@***.***> wrote:
@leebyron <https://github.com/leebyron> That makes sense. I believe that
@DxCx <https://github.com/dxcx> 's graphql-rxjs
<https://github.com/DxCx/graphql-rxjs> takes this approach, with a
separate executeReactive executor.
Would you consider a PR for adding reactive executors to the library at
this time? Thanks again!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#502 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADD0qIn6tej-PMBb9tcYQudSC40Kfwjks5tVxfsgaJpZM4KFbHW>
.
|
First Implementation for #501 .
NOTE: Promises still works, this change does not break any existing usage.
TODO:
take(1)
when non-reactive request executes and observable is resolved.