Class: GraphQL::DSL::InlineFragment

Inherits:
Node
  • Object
show all
Includes:
SelectionSet
Defined in:
lib/graphql/dsl/nodes/inline_fragment.rb

Overview

Inline fragment GraphQL node

Instance Attribute Summary collapse

Attributes inherited from Node

#__name, #__nodes

Instance Method Summary collapse

Methods included from SelectionSet

#__field, #__fragment, #__inline_fragment

Methods inherited from Node

#to_gql

Constructor Details

#initialize(type = nil, directives = [], &block) ⇒ InlineFragment

Create inline fragment

Parameters:

  • type (String, Symbol, nil) (defaults to: nil)

    fragment type

  • directives (Array<Directive, Hash, Array>) (defaults to: [])

    list of directives

  • block (Proc)

    declare DSL for sub-fields

Raises:



24
25
26
27
28
29
30
31
# File 'lib/graphql/dsl/nodes/inline_fragment.rb', line 24

def initialize(type = nil, directives = [], &block)
  raise Error, 'Sub-fields must be specified for inline fragment' if block.nil?

  @__type = type
  @__directives = directives.map { |directive| Directive.from(directive) }

  super(nil, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GraphQL::DSL::SelectionSet

Instance Attribute Details

#__directivesArray<Directive> (readonly)

Returns list of directives.

Returns:



16
17
18
# File 'lib/graphql/dsl/nodes/inline_fragment.rb', line 16

def __directives
  @__directives
end

#__typeString, ... (readonly)

Returns inline fragment type or interface.

Returns:

  • (String, Symbol, nil)

    inline fragment type or interface



12
13
14
# File 'lib/graphql/dsl/nodes/inline_fragment.rb', line 12

def __type
  @__type
end