Class: GraphQL::DSL::FragmentOperation

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

Overview

Fragment operation 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(name, type, directives = [], &block) ⇒ FragmentOperation

Create fragment operation

Parameters:

  • name (String, Symbol)

    fragment name

  • type (String, Symbol)

    fragment type or interface

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

    list of directives

  • block (Proc)

    declare DSL for sub-fields

Raises:



25
26
27
28
29
30
31
32
33
# File 'lib/graphql/dsl/nodes/fragment_operation.rb', line 25

def initialize(name, type, directives = [], &block)
  raise Error, '`name` must be specified' if name.nil? || name.empty?
  raise Error, '`type` must be specified' if type.nil? || type.empty?

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

  super(name, &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/fragment_operation.rb', line 16

def __directives
  @__directives
end

#__typeString, Symbol (readonly)

Returns fragment type or interface.

Returns:

  • (String, Symbol)

    fragment type or interface



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

def __type
  @__type
end