-
Notifications
You must be signed in to change notification settings - Fork 108
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
Promises fail to be resolved for Relay connection_type #26
Comments
Now that graphql-relay-ruby has been merged into graphql-ruby, we could probably be clearer about the fact that the relay code in graphql-ruby isn't supported by graphql-batch. We mention in the README that
and in this case you are trying to use the loader in a connection resolve proc, not on the field resolve proc. You may be able to support this by using GraphQL::Relay::BaseConnection.register_connection_implementation. |
Here's the simplest thing I could do convert over: module GraphQL
module Batch
class SyncPromiseConnection < GraphQL::Relay::ArrayConnection
def nodes
super.sync
end
end
end
end
GraphQL::Relay::BaseConnection.register_connection_implementation(GraphQL::Batch::Promise, GraphQL::Batch::SyncPromiseConnection) At least it lets this gem work by default with connections? Is it worth further investment (concern that it extends |
Calling sync like that would prevent batching. With graphql-ruby's new lazy execution API it will actually be possible to fix this upstream, so I'm going to consider this an upstream issue now and close the issue here. |
Upstream fix here! |
Is there an example on how to implement this? Using the association loader in the example folder would produce N+1 on connection types |
Relay support in graphql-ruby suggests resolvers for a
connection_type
should be able to return an array. Expect thatgraphql-batch
would support field resolver returning promise of an array in this scenario. It instead fails with exceptionNo connection implementation to wrap GraphQL::Batch::Promise
.A workaround is to have the resolver wait for promise fulfillment by calling Promise#sync on the
Loader#load/#load_many
result.@cjoudrey @dylanahsmith
For a repro, consider this script using
graphql (0.19.4)
andgraphql-batch (0.2.4)
onruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
:The text was updated successfully, but these errors were encountered: