Class: GraphQL::Query::Executor
- Inherits:
-
Object
- Object
- GraphQL::Query::Executor
- Defined in:
- lib/graphql/query/executor.rb
Defined Under Namespace
Classes: OperationNameMissingError
Instance Attribute Summary collapse
-
#operation_name ⇒ String
readonly
The operation to run in #query.
-
#query ⇒ GraphQL::Query
readonly
The query being executed.
Instance Method Summary collapse
-
#initialize(query, operation_name) ⇒ Executor
constructor
A new instance of Executor.
-
#result ⇒ Hash
Evalute #operation_name on #query.
Constructor Details
#initialize(query, operation_name) ⇒ Executor
Returns a new instance of Executor.
18 19 20 21 |
# File 'lib/graphql/query/executor.rb', line 18 def initialize(query, operation_name) @query = query @operation_name = operation_name end |
Instance Attribute Details
#operation_name ⇒ String (readonly)
Returns the operation to run in #query.
15 16 17 |
# File 'lib/graphql/query/executor.rb', line 15 def operation_name @operation_name end |
#query ⇒ GraphQL::Query (readonly)
Returns the query being executed.
12 13 14 |
# File 'lib/graphql/query/executor.rb', line 12 def query @query end |
Instance Method Details
#result ⇒ Hash
Evalute #operation_name on #query. Handle errors by putting them in the “errors” key. (Or, if ‘query.debug`, by re-raising them.)
26 27 28 29 30 31 32 33 34 |
# File 'lib/graphql/query/executor.rb', line 26 def result execute rescue OperationNameMissingError => err {"errors" => [{"message" => err.}]} rescue StandardError => err query.debug && raise(err) = "Something went wrong during query execution: #{err}" # \n #{err.backtrace.join("\n ")}" {"errors" => [{"message" => }]} end |