Class: ElasticGraph::SchemaDefinition::SchemaElements::Directive

Inherits:
Data
  • Object
show all
Includes:
Mixins::VerifiesGraphQLName
Defined in:
elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb,
elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb

Overview

Represents a GraphQL directive.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::VerifiesGraphQLName

verify_name!

Instance Attribute Details

#argumentsHash<Symbol, Object> (readonly)

Returns directive arguments.

Returns:

  • (Hash<Symbol, Object>)

    directive arguments



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb', line 22

class Directive < ::Data.define(:name, :arguments)
  prepend Mixins::VerifiesGraphQLName

  # @return [String] GraphQL SDL form of the directive
  def to_sdl
    %(@#{name}#{Support::GraphQLFormatter.format_args(**arguments)})
  end

  # Duplicates this directive on another GraphQL schema element.
  #
  # @param element [Argument, EnumType, EnumValue, Field, ScalarType, TypeWithSubfields, UnionType] schema element
  # @return [void]
  def duplicate_on(element)
    element.directive name, arguments
  end
end

#nameString (readonly)

Returns name of the directive.

Returns:

  • (String)

    name of the directive



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb', line 22

class Directive < ::Data.define(:name, :arguments)
  prepend Mixins::VerifiesGraphQLName

  # @return [String] GraphQL SDL form of the directive
  def to_sdl
    %(@#{name}#{Support::GraphQLFormatter.format_args(**arguments)})
  end

  # Duplicates this directive on another GraphQL schema element.
  #
  # @param element [Argument, EnumType, EnumValue, Field, ScalarType, TypeWithSubfields, UnionType] schema element
  # @return [void]
  def duplicate_on(element)
    element.directive name, arguments
  end
end

Instance Method Details

#duplicate_on(element) ⇒ void

This method returns an undefined value.

Duplicates this directive on another GraphQL schema element.

Parameters:



34
35
36
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb', line 34

def duplicate_on(element)
  element.directive name, arguments
end

#to_sdlString

Returns GraphQL SDL form of the directive.

Returns:

  • (String)

    GraphQL SDL form of the directive



26
27
28
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/directive.rb', line 26

def to_sdl
  %(@#{name}#{Support::GraphQLFormatter.format_args(**arguments)})
end