Class: GraphQL::Query::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query/executor.rb

Defined Under Namespace

Classes: OperationNameMissingError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query, operation_name) ⇒ Executor

Returns a new instance of Executor.



12
13
14
15
# File 'lib/graphql/query/executor.rb', line 12

def initialize(query, operation_name)
  @query = query
  @operation_name = operation_name
end

Instance Attribute Details

#operation_nameObject (readonly)

Returns the value of attribute operation_name.



11
12
13
# File 'lib/graphql/query/executor.rb', line 11

def operation_name
  @operation_name
end

#queryObject (readonly)

Returns the value of attribute query.



11
12
13
# File 'lib/graphql/query/executor.rb', line 11

def query
  @query
end

Instance Method Details

#resultObject



17
18
19
20
21
22
23
24
25
# File 'lib/graphql/query/executor.rb', line 17

def result
  {"data" => execute }
rescue OperationNameMissingError => err
  {"errors" => [{"message" => err.message}]}
rescue StandardError => err
  query.debug && raise(err)
  message = "Something went wrong during query execution: #{err}" # \n  #{err.backtrace.join("\n  ")}"
  {"errors" => [{"message" => message}]}
end