Class: Rails::GraphQL::Request::Component::Spread
- Inherits:
-
Rails::GraphQL::Request::Component
- Object
- Rails::GraphQL::Request::Component
- Rails::GraphQL::Request::Component::Spread
- Includes:
- Directives, SelectionSet
- Defined in:
- lib/rails/graphql/request/component/spread.rb
Overview
GraphQL Request Component Spread
This class holds information about a given spread that should be iterated, which connect to either a fragment or an inline selection
Instance Attribute Summary collapse
-
#current_object ⇒ Object
readonly
Returns the value of attribute current_object.
-
#fragment ⇒ Object
readonly
Returns the value of attribute fragment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type_klass ⇒ Object
readonly
Returns the value of attribute type_klass.
Attributes included from SelectionSet
Instance Method Summary collapse
-
#broadcastable? ⇒ Boolean
Check if all the sub fields or the fragment is broadcastable.
-
#cache_dump ⇒ Object
Build the cache object.
-
#cache_load(data) ⇒ Object
Organize from cache data.
-
#initialize(parent, node) ⇒ Spread
constructor
A new instance of Spread.
-
#inline? ⇒ Boolean
Check if the object is an inline spread.
-
#resolve_with!(object) ⇒ Object
Redirect to the fragment or check the inline type before resolving.
Methods included from Directives
#directive_events, #directive_listeners, #using?
Methods inherited from Rails::GraphQL::Request::Component
#assignable?, #hash, #invalid?, #invalidate!, kind, #skip!, #skipped?, #unresolvable?
Methods included from Resolvable
Methods included from Preparable
#prepare!, #prepared_data!, #prepared_data?
Methods included from Organizable
Constructor Details
#initialize(parent, node) ⇒ Spread
Returns a new instance of Spread.
19 20 21 22 23 24 25 26 |
# File 'lib/rails/graphql/request/component/spread.rb', line 19 def initialize(parent, node) @parent = parent @name = node[0] @inline = name.nil? super(node) end |
Instance Attribute Details
#current_object ⇒ Object (readonly)
Returns the value of attribute current_object.
17 18 19 |
# File 'lib/rails/graphql/request/component/spread.rb', line 17 def current_object @current_object end |
#fragment ⇒ Object (readonly)
Returns the value of attribute fragment.
17 18 19 |
# File 'lib/rails/graphql/request/component/spread.rb', line 17 def fragment @fragment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/rails/graphql/request/component/spread.rb', line 17 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
17 18 19 |
# File 'lib/rails/graphql/request/component/spread.rb', line 17 def parent @parent end |
#type_klass ⇒ Object (readonly)
Returns the value of attribute type_klass.
17 18 19 |
# File 'lib/rails/graphql/request/component/spread.rb', line 17 def type_klass @type_klass end |
Instance Method Details
#broadcastable? ⇒ Boolean
Check if all the sub fields or the fragment is broadcastable
34 35 36 |
# File 'lib/rails/graphql/request/component/spread.rb', line 34 def broadcastable? inline? ? selection.each_value.all?(&:broadcastable?) : fragment.broadcastable? end |
#cache_dump ⇒ Object
Build the cache object
49 50 51 |
# File 'lib/rails/graphql/request/component/spread.rb', line 49 def cache_dump inline? ? super.merge(type_klass: all_to_gid(type_klass)) : super end |
#cache_load(data) ⇒ Object
Organize from cache data
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rails/graphql/request/component/spread.rb', line 54 def cache_load(data) @name = data[:node][0] @inline = name.nil? if inline? @type_klass = all_from_gid(data[:type_klass]) else collect_fragment end super end |
#inline? ⇒ Boolean
Check if the object is an inline spread
29 30 31 |
# File 'lib/rails/graphql/request/component/spread.rb', line 29 def inline? @inline.present? end |
#resolve_with!(object) ⇒ Object
Redirect to the fragment or check the inline type before resolving
39 40 41 42 43 44 45 46 |
# File 'lib/rails/graphql/request/component/spread.rb', line 39 def resolve_with!(object) return if unresolvable? @current_object = object resolve! ensure @current_object = nil end |