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:



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

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:



31
32
33
# File 'lib/graphql/query/context.rb', line 31

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

#execution_errorsObject



35
36
37
# File 'lib/graphql/query/context.rb', line 35

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



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

def skip
  GraphQL::Execution::SKIP
end