Class: ActiveShopifyGraphQL::Query::Node
- Inherits:
-
Object
- Object
- ActiveShopifyGraphQL::Query::Node
- Defined in:
- lib/active_shopify_graphql/query/node.rb,
lib/active_shopify_graphql/query/node/raw.rb,
lib/active_shopify_graphql/query/node/field.rb,
lib/active_shopify_graphql/query/node/fragment.rb,
lib/active_shopify_graphql/query/node/singular.rb,
lib/active_shopify_graphql/query/node/collection.rb,
lib/active_shopify_graphql/query/node/connection.rb,
lib/active_shopify_graphql/query/node/single_record.rb,
lib/active_shopify_graphql/query/node/root_connection.rb,
lib/active_shopify_graphql/query/node/current_customer.rb,
lib/active_shopify_graphql/query/node/nested_connection.rb
Overview
Abstract base class for all GraphQL query nodes. Provides shared attributes and helper methods for node rendering.
Subclasses:
- Node::Field - Simple and nested fields
- Node::Singular - Singular associations (has_one)
- Node::Connection - Collection associations using nodes pattern
- Node::Fragment - Fragment definitions
- Node::Raw - Raw GraphQL strings
- Node::SingleRecord - Single record queries by ID
- Node::CurrentCustomer - ID-less queries (Customer Account API)
- Node::Collection - Collection queries with optional pagination
- Node::NestedConnection - Nested connection queries
- Node::RootConnection - Root-level connection queries
Direct Known Subclasses
Collection, Connection, CurrentCustomer, Field, Fragment, NestedConnection, Raw, RootConnection, SingleRecord, Singular
Defined Under Namespace
Classes: Collection, Connection, CurrentCustomer, Field, Fragment, NestedConnection, Raw, RootConnection, SingleRecord, Singular
Constant Summary collapse
- PAGE_INFO_FIELDS =
Shared constants for query formatting
"pageInfo { hasNextPage hasPreviousPage startCursor endCursor }"- STRING_KEYS_NEEDING_QUOTES =
i[query after before].freeze
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#add_child(node) ⇒ Object
Add a child node.
-
#has_children? ⇒ Boolean
Check if node has children.
-
#initialize(name:, alias_name: nil, arguments: {}, children: []) ⇒ Node
constructor
A new instance of Node.
-
#to_s ⇒ Object
Convert node to GraphQL string - must be implemented by subclasses.
Constructor Details
#initialize(name:, alias_name: nil, arguments: {}, children: []) ⇒ Node
Returns a new instance of Node.
29 30 31 32 33 34 |
# File 'lib/active_shopify_graphql/query/node.rb', line 29 def initialize(name:, alias_name: nil, arguments: {}, children: []) @name = name @alias_name = alias_name @arguments = arguments @children = children end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
23 24 25 |
# File 'lib/active_shopify_graphql/query/node.rb', line 23 def alias_name @alias_name end |
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
23 24 25 |
# File 'lib/active_shopify_graphql/query/node.rb', line 23 def arguments @arguments end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
23 24 25 |
# File 'lib/active_shopify_graphql/query/node.rb', line 23 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/active_shopify_graphql/query/node.rb', line 23 def name @name end |
Instance Method Details
#add_child(node) ⇒ Object
Add a child node
37 38 39 40 |
# File 'lib/active_shopify_graphql/query/node.rb', line 37 def add_child(node) @children << node node end |
#has_children? ⇒ Boolean
Check if node has children
43 44 45 |
# File 'lib/active_shopify_graphql/query/node.rb', line 43 def has_children? @children.any? end |
#to_s ⇒ Object
Convert node to GraphQL string - must be implemented by subclasses
48 49 50 |
# File 'lib/active_shopify_graphql/query/node.rb', line 48 def to_s raise NotImplementedError, "#{self.class} must implement #to_s" end |