Class: ActiveShopifyGraphQL::Query::Node::SingleRecord

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

Overview

Renders a single record query by ID. Example:

query getCustomer($id: ID!) {
customer(id: $id) {
  ...CustomerFragment
}
}

Constant Summary

Constants inherited from ActiveShopifyGraphQL::Query::Node

PAGE_INFO_FIELDS, STRING_KEYS_NEEDING_QUOTES

Instance Attribute Summary collapse

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?

Constructor Details

#initialize(model_type:, query_name:, fragment_name:, fragments: []) ⇒ SingleRecord

Returns a new instance of SingleRecord.



16
17
18
19
20
21
22
# File 'lib/active_shopify_graphql/query/node/single_record.rb', line 16

def initialize(model_type:, query_name:, fragment_name:, fragments: [])
  @model_type = model_type
  @query_name = query_name
  @fragment_name = fragment_name
  @fragments = fragments
  super(name: query_name)
end

Instance Attribute Details

#fragment_nameObject (readonly)

Returns the value of attribute fragment_name.



14
15
16
# File 'lib/active_shopify_graphql/query/node/single_record.rb', line 14

def fragment_name
  @fragment_name
end

#fragmentsObject (readonly)

Returns the value of attribute fragments.



14
15
16
# File 'lib/active_shopify_graphql/query/node/single_record.rb', line 14

def fragments
  @fragments
end

#model_typeObject (readonly)

Returns the value of attribute model_type.



14
15
16
# File 'lib/active_shopify_graphql/query/node/single_record.rb', line 14

def model_type
  @model_type
end

#query_nameObject (readonly)

Returns the value of attribute query_name.



14
15
16
# File 'lib/active_shopify_graphql/query/node/single_record.rb', line 14

def query_name
  @query_name
end

Instance Method Details

#to_sObject



24
25
26
# File 'lib/active_shopify_graphql/query/node/single_record.rb', line 24

def to_s
  "#{fragments_string} query get#{model_type}($id: ID!) { #{query_name}(id: $id) { ...#{fragment_name} } }"
end