Class: ActiveShopifyGraphQL::Query::Node::Field

Inherits:
ActiveShopifyGraphQL::Query::Node show all
Defined in:
lib/active_shopify_graphql/query/node/field.rb

Overview

Renders simple fields and nested fields with children. Examples:

- Simple: `id`
- With alias: `customerId: id`
- Nested: `defaultAddress { city country }`

Constant Summary

Constants inherited from ActiveShopifyGraphQL::Query::Node

PAGE_INFO_FIELDS, STRING_KEYS_NEEDING_QUOTES

Instance Attribute Summary

Attributes inherited from ActiveShopifyGraphQL::Query::Node

#alias_name, #arguments, #children, #name

Instance Method Summary collapse

Methods inherited from ActiveShopifyGraphQL::Query::Node

#add_child, #has_children?, #initialize

Constructor Details

This class inherits a constructor from ActiveShopifyGraphQL::Query::Node

Instance Method Details

#to_sObject



12
13
14
15
16
17
18
19
# File 'lib/active_shopify_graphql/query/node/field.rb', line 12

def to_s
  full_name = "#{field_name_with_alias}#{format_arguments}"

  return full_name unless has_children?

  nested_fields = render_children
  "#{full_name} { #{nested_fields.join(' ')} }"
end