Class: ActiveShopifyGraphQL::Query::Node::NestedConnection

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

Overview

Renders a nested connection query (loaded from a parent record). Example:

query($id: ID!) {
customer(id: $id) {
  orders(first: 10) {
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    nodes {
      ...OrderFragment
    }
  }
}
}

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:, parent_query:, variables: {}, fragments: [], singular: false) ⇒ NestedConnection

Returns a new instance of NestedConnection.



26
27
28
29
30
31
32
33
34
# File 'lib/active_shopify_graphql/query/node/nested_connection.rb', line 26

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

Instance Attribute Details

#fragment_nameObject (readonly)

Returns the value of attribute fragment_name.



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

def fragment_name
  @fragment_name
end

#fragmentsObject (readonly)

Returns the value of attribute fragments.



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

def fragments
  @fragments
end

#parent_queryObject (readonly)

Returns the value of attribute parent_query.



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

def parent_query
  @parent_query
end

#query_nameObject (readonly)

Returns the value of attribute query_name.



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

def query_name
  @query_name
end

#singularObject (readonly)

Returns the value of attribute singular.



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

def singular
  @singular
end

#variablesObject (readonly)

Returns the value of attribute variables.



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

def variables
  @variables
end

Instance Method Details

#to_sObject



36
37
38
39
40
41
42
# File 'lib/active_shopify_graphql/query/node/nested_connection.rb', line 36

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