Module: Rails::GraphQL::Request::SelectionSet
- Included in:
- Component::Field, Component::Fragment, Component::Operation, Component::Spread
- Defined in:
- lib/rails/graphql/request/helpers/selection_set.rb
Overview
Helper module to collect the fields from fragments, operations, and also other fields.
Instance Attribute Summary collapse
-
#selection ⇒ Object
readonly
Returns the value of attribute selection.
Instance Method Summary collapse
-
#cache_dump ⇒ Object
Build the cache object.
-
#cache_load(data) ⇒ Object
Organize from cache data.
Instance Attribute Details
#selection ⇒ Object (readonly)
Returns the value of attribute selection.
9 10 11 |
# File 'lib/rails/graphql/request/helpers/selection_set.rb', line 9 def selection @selection end |
Instance Method Details
#cache_dump ⇒ Object
Build the cache object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rails/graphql/request/helpers/selection_set.rb', line 12 def cache_dump return super unless defined?(@selection) selection = @selection.transform_values do |field| field.cache_dump.merge(type: field.class) end super.merge(selection: selection) end |
#cache_load(data) ⇒ Object
Organize from cache data
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails/graphql/request/helpers/selection_set.rb', line 23 def cache_load(data) return super unless data.key?(:selection) @selection = data[:selection].transform_values do |data| component = request.build_from_cache(data[:type]) component.instance_variable_set(:@parent, self) component.cache_load(data) component end.freeze super end |