Method: GraphQL::Query::Executor#result

Defined in:
lib/graphql/query/executor.rb

#resultHash

Evalute operation_name on #query. Handle errors by putting them in the “errors” key. (Or, if query.debug, by re-raising them.)

Returns:

  • (Hash)

    A GraphQL response, with either a “data” key or an “errors” key



14
15
16
17
18
19
20
21
22
# File 'lib/graphql/query/executor.rb', line 14

def result
  execute
rescue GraphQL::Query::OperationNameMissingError, GraphQL::Query::VariableMissingError => 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