-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Defer directive #168
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
Defer directive #168
Conversation
lib/graphql/schema.rb
Outdated
@@ -42,7 +46,7 @@ def initialize(query:, mutation: nil, subscription: nil, max_depth: nil, types: | |||
@rescue_middleware = GraphQL::Schema::RescueMiddleware.new | |||
@middleware = [@rescue_middleware] | |||
# Default to the built-in execution strategy: | |||
self.query_execution_strategy = GraphQL::Query::SerialExecution | |||
self.query_execution_strategy = GraphQL::Execution::DeferredExecution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't actually want to make this default yet, I just need a way to run the whole test suite on it
6bb621b
to
b5e0ae4
Compare
I really want this 😄 |
a6c069a
to
be22067
Compare
Pushed demo here: https://github.com/rmosolgo/graphql-ruby-stream-defer-demo |
b626570
to
8e7700c
Compare
I merged some of the refactors from this branch into master, that way it will be easier to keep this branch up to date. |
Some implementations https://github.com/rmosolgo/graphql-streaming |
This is amazing. At Zendesk we have a fairly large application written on Are you actively working on shipping |
The big todo before putting this in master is fixing this problem: Tests which depend on
I think eventually, As for There's one deficiency in the client, and I'm not sure how to beat it yet: when we receive incoming patches, we re-split the entire patch string, instead of just identifying the newly-added part. As the patch string grows, the cost of splitting it grows. I'm not sure how bad the cost is, but you can see the relevant lines here: https://github.com/rmosolgo/graphql-streaming/blob/master/lib/graphql/streaming/clients/graphql-streaming/streaming_graphql_client.js#L39-L41 |
a03b48b
to
42138c1
Compare
So this is perhaps a bit of a side-issue, but maybe this is a good place to ask anyway. I'm trying to take a look at the various places where outside code can plug functionality into graphql-ruby, and it's principally two places:
That second one, different execution strategies, is a bit confusing for me. To be honest, my knowledge of execution strategies doesn't go much further than, "You have to add this line of code for graphql-batch to work," and there's a similar line that makes I'm wondering if execution strategy is not really a good extensibility point? We're already thinking that async should be part of the core library (this would obviate graphql-batch's execution strategy, right?), and it looks like DeferredExecution could replace SerialExecution. It seems that if graphql-ruby took a stance on execution strategy, we'd gain:
From what I can see, the casualty would be parallel execution. My thoughts on that, though:
|
Totally agree! From my perspective, this feature is next on my list, for all the reasons you mentioned (plus because it will fix all the I think you're right about |
aa81e7a
to
3924bcc
Compare
3924bcc
to
9ace98d
Compare
Someday 🌥 |
Hi @rmosolgo Using this library for a while now. Really loving it :) But we are missing the the |
I'm hoping to rewrite the GraphQL runtime this summer, and supporting custom directives is one of the requirements :) My first tinkering is on #1394 , keep an eye there or watch this repo to follow development. |
This is the first step to support
@defer
and@stream
as described in https://www.youtube.com/watch?v=ViXL0YQnioUTODO:
@defer
@stream
Good API for providing a collector for query resolutionI think injection bycontext:
is ok, you'll need to make new instances all the time anyways because they have to contain their patch targetsCan we be more efficient with Frames and new path arrays? in some cases we don't need new ones?I think it's fine, if you made a new one before finishing a returned value, you'd waste it sometimes but use it verbatim other times, not clear if it would be an improvementHandle case whennot a problem, middleware actually returns the error@defer
'd field raises an error which is rescued by middleware (stop usingquery.context
)nil
(because they may be non-null types)