Class: GraphQL::Client::Query::InlineFragment

Inherits:
Object
  • Object
show all
Includes:
HasSelectionSet
Defined in:
lib/graphql_client/query/inline_fragment.rb

Constant Summary

Constants included from HasSelectionSet

HasSelectionSet::ID_FIELD_NAME, HasSelectionSet::INVALID_FIELD, HasSelectionSet::UNDEFINED_FRAGMENT

Instance Attribute Summary collapse

Attributes included from HasSelectionSet

#selection_set

Instance Method Summary collapse

Methods included from HasSelectionSet

#add_connection, #add_field, #add_fields, #add_fragment

Constructor Details

#initialize(type, document:) {|_self| ... } ⇒ InlineFragment

Returns a new instance of InlineFragment.

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
15
16
17
# File 'lib/graphql_client/query/inline_fragment.rb', line 11

def initialize(type, document:)
  @type = type
  @document = document
  @selection_set = SelectionSet.new

  yield self if block_given?
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



9
10
11
# File 'lib/graphql_client/query/inline_fragment.rb', line 9

def document
  @document
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/graphql_client/query/inline_fragment.rb', line 9

def type
  @type
end

Instance Method Details

#resolver_typeObject



19
20
21
# File 'lib/graphql_client/query/inline_fragment.rb', line 19

def resolver_type
  type
end

#to_query(indent: '') ⇒ Object Also known as: to_s



23
24
25
26
27
28
29
# File 'lib/graphql_client/query/inline_fragment.rb', line 23

def to_query(indent: '')
  indent.dup.tap do |query_string|
    query_string << "... on #{type.name} {\n"
    query_string << selection_set.to_query(indent)
    query_string << "\n#{indent}}"
  end
end