Class: GraphQL::Query::Context::FieldResolutionContext
- Inherits:
- 
      Object
      
        - Object
- GraphQL::Query::Context::FieldResolutionContext
 
- Extended by:
- Forwardable
- Includes:
- SharedMethods, Tracing::Traceable
- Defined in:
- lib/graphql/query/context.rb
Instance Attribute Summary collapse
- 
  
    
      #field  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute field. 
- 
  
    
      #irep_node  ⇒ Object 
    
    
      (also: #selection)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute irep_node. 
- 
  
    
      #key  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute key. 
- 
  
    
      #parent  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute parent. 
- 
  
    
      #parent_type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute parent_type. 
- 
  
    
      #query  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute query. 
- 
  
    
      #schema  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute schema. 
- 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute type. 
- 
  
    
      #wrapped_connection  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  private
  
    
- 
  
    
      #wrapped_object  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  private
  
    
Attributes included from SharedMethods
Instance Method Summary collapse
- 
  
    
      #add_error(error)  ⇒ void 
    
    
  
  
  
  
  
  
  
  
  
    Add error to current field resolution. 
- 
  
    
      #ast_node  ⇒ GraphQL::Language::Nodes::Field 
    
    
  
  
  
  
  
  
  
  
  
    The AST node for the currently-executing field. 
- 
  
    
      #initialize(context, key, irep_node, parent, object)  ⇒ FieldResolutionContext 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of FieldResolutionContext. 
- 
  
    
      #inspect  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
- 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
- 
  
    
      #value=(new_value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    Set a new value for this field in the response. 
Methods included from Tracing::Traceable
Methods included from SharedMethods
#backtrace, #delete_child, #execution_errors, #invalid_null?, #lookahead, #skip, #spawn_child
Constructor Details
#initialize(context, key, irep_node, parent, object) ⇒ FieldResolutionContext
Returns a new instance of FieldResolutionContext.
| 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | # File 'lib/graphql/query/context.rb', line 276 def initialize(context, key, irep_node, parent, object) @context = context @key = key @parent = parent @object = object @irep_node = irep_node @field = irep_node.definition @parent_type = irep_node.owner_type @type = field.type # This is needed constantly, so set it ahead of time: @query = context.query @schema = context.schema @tracers = @query.tracers # This hack flag is required by ConnectionResolve @wrapped_connection = false @wrapped_object = false end | 
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def field @field end | 
#irep_node ⇒ Object (readonly) Also known as: selection
Returns the value of attribute irep_node.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def irep_node @irep_node end | 
#key ⇒ Object (readonly)
Returns the value of attribute key.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def key @key end | 
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def parent @parent end | 
#parent_type ⇒ Object (readonly)
Returns the value of attribute parent_type.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def parent_type @parent_type end | 
#query ⇒ Object (readonly)
Returns the value of attribute query.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def query @query end | 
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def schema @schema end | 
#type ⇒ Object (readonly)
Returns the value of attribute type.
| 273 274 275 | # File 'lib/graphql/query/context.rb', line 273 def type @type end | 
#wrapped_connection ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 295 296 297 | # File 'lib/graphql/query/context.rb', line 295 def wrapped_connection @wrapped_connection end | 
#wrapped_object ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 295 296 297 | # File 'lib/graphql/query/context.rb', line 295 def wrapped_object @wrapped_object end | 
Instance Method Details
#add_error(error) ⇒ void
This method returns an undefined value.
Add error to current field resolution.
| 314 315 316 317 318 319 | # File 'lib/graphql/query/context.rb', line 314 def add_error(error) super error.ast_node ||= irep_node.ast_node error.path ||= path nil end | 
#ast_node ⇒ GraphQL::Language::Nodes::Field
Returns The AST node for the currently-executing field.
| 307 308 309 | # File 'lib/graphql/query/context.rb', line 307 def ast_node @irep_node.ast_node end | 
#inspect ⇒ Object
| 321 322 323 | # File 'lib/graphql/query/context.rb', line 321 def inspect "#<GraphQL Context @ #{irep_node.owner_type.name}.#{field.name}>" end | 
#path ⇒ Object
| 297 298 299 | # File 'lib/graphql/query/context.rb', line 297 def path @path ||= @parent.path.dup << @key end | 
#value=(new_value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set a new value for this field in the response. It may be updated after resolving a Lazy. If it is Execute::PROPAGATE_NULL, tell the owner to propagate null. If it’s Execute::Execution::SKIP, remove this field result from its parent
| 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | # File 'lib/graphql/query/context.rb', line 331 def value=(new_value) case new_value when GraphQL::Execution::Execute::PROPAGATE_NULL, nil @invalid_null = true @value = nil if @type.kind.non_null? @parent.received_null_child end when GraphQL::Execution::Execute::SKIP @parent.skipped = true @parent.delete_child(self) else @value = new_value end end |