Class: GraphQL::Execution::SelectionResult Private
- Inherits:
-
Object
- Object
- GraphQL::Execution::SelectionResult
- Defined in:
- lib/graphql/execution/selection_result.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A set of key-value pairs suitable for a GraphQL response.
Instance Method Summary collapse
-
#each ⇒ Object
private
Visit each key-result pair in this result.
-
#fetch(key) ⇒ FieldResult
private
The result for this field.
-
#initialize ⇒ SelectionResult
constructor
private
A new instance of SelectionResult.
-
#invalid_null? ⇒ Boolean
private
True if this selection has been nullified by a null child.
- #owner=(field_result) ⇒ Object private
-
#propagate_null ⇒ Object
private
A field has been unexpectedly nullified.
- #set(key, field_result) ⇒ Object private
-
#to_h ⇒ Hash
private
A plain Hash representation of this result.
Constructor Details
#initialize ⇒ SelectionResult
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.
Returns a new instance of SelectionResult.
7 8 9 10 11 |
# File 'lib/graphql/execution/selection_result.rb', line 7 def initialize @storage = {} @owner = nil @invalid_null = false end |
Instance Method Details
#each ⇒ 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.
Visit each key-result pair in this result
26 27 28 29 30 |
# File 'lib/graphql/execution/selection_result.rb', line 26 def each @storage.each do |key, field_res| yield(key, field_res) end end |
#fetch(key) ⇒ FieldResult
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.
Returns The result for this field.
21 22 23 |
# File 'lib/graphql/execution/selection_result.rb', line 21 def fetch(key) @storage.fetch(key) end |
#invalid_null? ⇒ Boolean
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.
Returns True if this selection has been nullified by a null child.
52 53 54 |
# File 'lib/graphql/execution/selection_result.rb', line 52 def invalid_null? @invalid_null end |
#owner=(field_result) ⇒ 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.
57 58 59 60 61 62 63 |
# File 'lib/graphql/execution/selection_result.rb', line 57 def owner=(field_result) if @owner raise("Can't change owners of SelectionResult") else @owner = field_result end end |
#propagate_null ⇒ 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.
A field has been unexpectedly nullified. Tell the owner FieldResult if it is present. Record #invalid_null in case an owner is added later.
44 45 46 47 48 49 |
# File 'lib/graphql/execution/selection_result.rb', line 44 def propagate_null if @owner @owner.value = GraphQL::Execution::Execute::PROPAGATE_NULL end @invalid_null = true end |
#set(key, field_result) ⇒ 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.
15 16 17 |
# File 'lib/graphql/execution/selection_result.rb', line 15 def set(key, field_result) @storage[key] = field_result end |
#to_h ⇒ Hash
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.
Returns A plain Hash representation of this result.
33 34 35 36 37 38 39 |
# File 'lib/graphql/execution/selection_result.rb', line 33 def to_h if @invalid_null nil else flatten(self) end end |