Module: GraphQL::Query::Context::SharedMethods

Included in:
GraphQL::Query::Context
Defined in:
lib/graphql/query/context.rb

Instance Method Summary collapse

Instance Method Details

#add_error(error) ⇒ void

This method returns an undefined value.

Add error at query-level.

Parameters:


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

def add_error(error)
  if !error.is_a?(ExecutionError)
    raise TypeError, "expected error to be a ExecutionError, but was #{error.class}"
  end
  errors << error
  nil
end

#backtraceGraphQL::Backtrace

Returns The backtrace for this point in query execution.

Examples:

Print the GraphQL backtrace during field resolution

puts ctx.backtrace

Returns:


29
30
31
# File 'lib/graphql/query/context.rb', line 29

def backtrace
  GraphQL::Backtrace.new(self)
end

#execution_errorsObject


33
34
35
# File 'lib/graphql/query/context.rb', line 33

def execution_errors
  @execution_errors ||= ExecutionErrors.new(self)
end

#skipObject

Return this value to tell the runtime to exclude this field from the response altogether


10
11
12
# File 'lib/graphql/query/context.rb', line 10

def skip
  GraphQL::Execution::SKIP
end