Class: GraphQL::DSL::Field

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

Overview

Field 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(field_name, field_alias = nil, arguments = {}, directives = [], &block) ⇒ Field

Create field

Parameters:

  • field_name (String, Symbol)

    field name

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

    field alias

  • arguments (Hash) (defaults to: {})

    field arguments

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

    list of directives

  • block (Proc)

    declare DSL for sub-fields



30
31
32
33
34
35
36
# File 'lib/graphql/dsl/nodes/field.rb', line 30

def initialize(field_name, field_alias = nil, arguments = {}, directives = [], &block)
  @__alias = field_alias
  @__arguments = arguments
  @__directives = directives.map { |directive| Directive.from(directive) }

  super(field_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

#__aliasString, ... (readonly)

Returns field alias.

Returns:

  • (String, Symbol, nil)

    field alias



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

def __alias
  @__alias
end

#__argumentsHash (readonly)

Returns list of filed arguments.

Returns:

  • (Hash)

    list of filed arguments



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

def __arguments
  @__arguments
end

#__directivesArray<Directive> (readonly)

Returns list of directives.

Returns:



20
21
22
# File 'lib/graphql/dsl/nodes/field.rb', line 20

def __directives
  @__directives
end