Class: GraphQL::Client::Node
- Inherits:
-
Object
- Object
- GraphQL::Client::Node
- Defined in:
- lib/graphql/client/node.rb
Instance Attribute Summary collapse
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node, fragments) ⇒ Node
constructor
A new instance of Node.
- #new(*args) ⇒ Object
Constructor Details
#initialize(node, fragments) ⇒ Node
Returns a new instance of Node.
25 26 27 28 29 |
# File 'lib/graphql/client/node.rb', line 25 def initialize(node, fragments) @node = node @fragments = fragments @type = node.query_result_class(shadow: fragments) end |
Instance Attribute Details
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
21 22 23 |
# File 'lib/graphql/client/node.rb', line 21 def fragments @fragments end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
19 20 21 |
# File 'lib/graphql/client/node.rb', line 19 def node @node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/graphql/client/node.rb', line 23 def type @type end |
Class Method Details
.scan_interpolated_fragments(str) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/graphql/client/node.rb', line 8 def self.scan_interpolated_fragments(str) fragments, index = {}, 1 str = str.gsub(/\.\.\.([a-zA-Z0-9_]+(::[a-zA-Z0-9_]+)+)/) { |m| index += 1 name = "__fragment#{index}__" fragments[name.to_sym] = ActiveSupport::Inflector.constantize($1).node "...#{name}" } return str, fragments end |
Instance Method Details
#new(*args) ⇒ Object
31 32 33 |
# File 'lib/graphql/client/node.rb', line 31 def new(*args) type.new(*args) end |