Skip to content

Instantly share code, notes, and snippets.

@jonniesweb
Last active April 3, 2018 02:15
Show Gist options
  • Save jonniesweb/98870831d03616fad49b174ecfc23422 to your computer and use it in GitHub Desktop.
Save jonniesweb/98870831d03616fad49b174ecfc23422 to your computer and use it in GitHub Desktop.
Using Concurrent::Future as return values in GraphQL Ruby
# app/graphql/types/query_type.rb
Types::QueryType = GraphQL::ObjectType.define do
name "Query"
field :ticket, types.String do
resolve ->(obj, args, ctx) {
Concurrent::Future.execute do
BackendTicketService.fetch(1234)
end
}
end
end
# app/graphql/app_schema.rb
AppSchema = GraphQL::Schema.define do
query(Types::QueryType)
lazy_resolve(Concurrent::Future, :value!)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment