0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Extend the GraphQL gem by allowing for one level of asynchronous field resolution.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.17
~> 0.9.4
 Project Readme

GraphQL::Parallel

Build Status

Provides one layer of asynchronous field resolution to the graphql gem, backed by Celluloid.

Installation

Add this line to your application's Gemfile:

gem 'graphql-parallel'

And then execute:

$ bundle

Or install it yourself as:

$ gem install graphql-parallel

Usage

Require GraphQL::Parallel:

require 'graphql/parallel'

Use context.async in your field resolve functions:

resolve -> (obj, args, context) do
  # resolve other fields while this request
  # is in progress:
  context.async do
    response = Net::HTTP.get_response(obj.uri)
    response.body
  end
end

Use GraphQL::Parallel::ExecutionStrategy for your schema's read queries:

# Define your schema:
MySchema = GraphQL::Schema.new(query: MyQueryType)

# Use parallel execution for read queries:
MySchema.query_execution_strategy = GraphQL::Parallel::ExecutionStrategy

(MySchema will still use the default sequential execution strategy for mutations.)

License

MIT