Class: ActiveShopifyGraphQL::Query::Node::RootConnection

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

Overview

Renders a root-level connection query (no parent record). Example:

query {
customers(first: 10) {
  pageInfo {
    hasNextPage
    hasPreviousPage
    startCursor
    endCursor
  }
  nodes {
    ...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(query_name:, fragment_name:, variables: {}, fragments: [], singular: false) ⇒ RootConnection

Returns a new instance of RootConnection.



24
25
26
27
28
29
30
31
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 24

def initialize(query_name:, fragment_name:, variables: {}, fragments: [], singular: false)
  @query_name = query_name
  @fragment_name = fragment_name
  @variables = variables
  @fragments = fragments
  @singular = singular
  super(name: query_name)
end

Instance Attribute Details

#fragment_nameObject (readonly)

Returns the value of attribute fragment_name.



22
23
24
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 22

def fragment_name
  @fragment_name
end

#fragmentsObject (readonly)

Returns the value of attribute fragments.



22
23
24
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 22

def fragments
  @fragments
end

#query_nameObject (readonly)

Returns the value of attribute query_name.



22
23
24
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 22

def query_name
  @query_name
end

#singularObject (readonly)

Returns the value of attribute singular.



22
23
24
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 22

def singular
  @singular
end

#variablesObject (readonly)

Returns the value of attribute variables.



22
23
24
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 22

def variables
  @variables
end

Instance Method Details

#to_sObject



33
34
35
36
37
38
39
# File 'lib/active_shopify_graphql/query/node/root_connection.rb', line 33

def to_s(*)
  if @singular
    render_singular_connection
  else
    render_nodes_connection
  end
end