Class: GraphQL::Client::Query::Fragment
- Inherits:
-
Object
- Object
- GraphQL::Client::Query::Fragment
- Includes:
- AddInlineFragment, HasSelectionSet
- Defined in:
- lib/graphql_client/query/fragment.rb
Constant Summary
Constants included from HasSelectionSet
HasSelectionSet::ID_FIELD_NAME, HasSelectionSet::INVALID_FIELD, HasSelectionSet::UNDEFINED_FRAGMENT
Constants included from AddInlineFragment
AddInlineFragment::INVALID_FRAGMENT_TARGET
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes included from HasSelectionSet
Instance Method Summary collapse
-
#initialize(name, type, document:) {|_self| ... } ⇒ Fragment
constructor
A new instance of Fragment.
- #resolver_type ⇒ Object
- #to_definition(indent: '') ⇒ Object
- #to_query(indent: '') ⇒ Object (also: #to_s)
Methods included from HasSelectionSet
#add_connection, #add_field, #add_fields, #add_fragment
Methods included from AddInlineFragment
Constructor Details
#initialize(name, type, document:) {|_self| ... } ⇒ Fragment
Returns a new instance of Fragment.
12 13 14 15 16 17 18 19 |
# File 'lib/graphql_client/query/fragment.rb', line 12 def initialize(name, type, document:) @name = name @type = type @document = document @selection_set = SelectionSet.new yield self if block_given? end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
10 11 12 |
# File 'lib/graphql_client/query/fragment.rb', line 10 def document @document end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/graphql_client/query/fragment.rb', line 10 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/graphql_client/query/fragment.rb', line 10 def type @type end |
Instance Method Details
#resolver_type ⇒ Object
21 22 23 |
# File 'lib/graphql_client/query/fragment.rb', line 21 def resolver_type type end |
#to_definition(indent: '') ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/graphql_client/query/fragment.rb', line 25 def to_definition(indent: '') indent.dup.tap do |query_string| query_string << "fragment #{name} on #{type.name} {\n" query_string << selection_set.to_query(indent) query_string << "\n#{indent}}\n" end end |
#to_query(indent: '') ⇒ Object Also known as: to_s
33 34 35 |
# File 'lib/graphql_client/query/fragment.rb', line 33 def to_query(indent: '') "#{indent}...#{name}" end |