Module: ElasticGraph::SchemaDefinition::Mixins::VerifiesGraphQLName
- Included in:
- SchemaElements::Argument, SchemaElements::Directive, SchemaElements::EnumType, SchemaElements::EnumValue, SchemaElements::Field, SchemaElements::ScalarType, SchemaElements::TypeWithSubfields, SchemaElements::UnionType
- Defined in:
- lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb
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
-
.verify_name!(name) ⇒ void
Raises if the provided name is invalid.
Instance Method Summary collapse
Class Method Details
.verify_name!(name) ⇒ void
This method returns an undefined value.
Raises if the provided 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
#initialize ⇒ Object
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 |