Class: ActiveShopifyGraphQL::Query::Node::Collection
- Inherits:
-
ActiveShopifyGraphQL::Query::Node
- Object
- ActiveShopifyGraphQL::Query::Node
- ActiveShopifyGraphQL::Query::Node::Collection
- Defined in:
- lib/active_shopify_graphql/query/node/collection.rb
Overview
Renders a collection query with optional pagination. Example without pagination:
query getCustomers {
customers(first: 10) {
nodes {
...CustomerFragment
}
}
}
Example with pagination:
query getCustomers {
customers(first: 10, after: "cursor") {
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
-
#fragment_name ⇒ Object
readonly
Returns the value of attribute fragment_name.
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
-
#include_page_info ⇒ Object
readonly
Returns the value of attribute include_page_info.
-
#model_type ⇒ Object
readonly
Returns the value of attribute model_type.
-
#query_name ⇒ Object
readonly
Returns the value of attribute query_name.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Attributes inherited from ActiveShopifyGraphQL::Query::Node
#alias_name, #arguments, #children, #name
Instance Method Summary collapse
-
#initialize(model_type:, query_name:, fragment_name:, variables: {}, fragments: [], include_page_info: false) ⇒ Collection
constructor
A new instance of Collection.
- #to_s ⇒ Object
Methods inherited from ActiveShopifyGraphQL::Query::Node
Constructor Details
#initialize(model_type:, query_name:, fragment_name:, variables: {}, fragments: [], include_page_info: false) ⇒ Collection
Returns a new instance of Collection.
33 34 35 36 37 38 39 40 41 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 33 def initialize(model_type:, query_name:, fragment_name:, variables: {}, fragments: [], include_page_info: false) @model_type = model_type @query_name = query_name @fragment_name = fragment_name @variables = variables @fragments = fragments @include_page_info = include_page_info super(name: query_name) end |
Instance Attribute Details
#fragment_name ⇒ Object (readonly)
Returns the value of attribute fragment_name.
31 32 33 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 31 def fragment_name @fragment_name end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
31 32 33 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 31 def fragments @fragments end |
#include_page_info ⇒ Object (readonly)
Returns the value of attribute include_page_info.
31 32 33 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 31 def include_page_info @include_page_info end |
#model_type ⇒ Object (readonly)
Returns the value of attribute model_type.
31 32 33 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 31 def model_type @model_type end |
#query_name ⇒ Object (readonly)
Returns the value of attribute query_name.
31 32 33 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 31 def query_name @query_name end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
31 32 33 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 31 def variables @variables end |
Instance Method Details
#to_s ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/active_shopify_graphql/query/node/collection.rb', line 43 def to_s parts = [fragments_string, "query get#{model_type.pluralize} { #{query_name}#{field_signature} {"] parts << PAGE_INFO_FIELDS if @include_page_info parts << "nodes { ...#{fragment_name} }" parts << "} }" parts.join(' ') end |