Module: ElasticGraph::SchemaDefinition::Mixins::VerifiesGraphQLName

Overview

Note:

This mixin is designed to be used via ‘prepend`, so it can add a constructor override that enforces

Used to verify the validity of the name of GraphQL schema elements.

the GraphQL name pattern as the object is built.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.verify_name!(name) ⇒ void

This method returns an undefined value.

Raises if the provided name is invalid.

Parameters:

  • name (String)

    name of GraphQL schema element

Raises:

  • (Errors::InvalidGraphQLNameError)

    if the name is invalid



31
32
33
34
# File 'lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb', line 31

def self.verify_name!(name)
  return if GRAPHQL_NAME_PATTERN.match?(name)
  raise Errors::InvalidGraphQLNameError, "Not a valid GraphQL name: `#{name}`. #{GRAPHQL_NAME_VALIDITY_DESCRIPTION}"
end

Instance Method Details

#initializeObject



20
21
22
23
24
# File 'lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb', line 20

def initialize(...)
  __skip__ = super(...) # __skip__ tells Steep to ignore this

  VerifiesGraphQLName.verify_name!(name)
end