Class: ElasticGraph::SchemaDefinition::SchemaElements::Argument
- Inherits:
-
Struct
- Object
- Struct
- ElasticGraph::SchemaDefinition::SchemaElements::Argument
- Includes:
- Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::SupportsDefaultValue, Mixins::VerifiesGraphQLName
- Defined in:
- elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb
Overview
Represents a GraphQL argument.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Name of the argument.
-
#original_value_type ⇒ TypeReference
readonly
Type of the argument, as originally provided.
-
#parent_field ⇒ Field
readonly
Field which has this argument.
-
#schema_def_state ⇒ State
readonly
State of the schema.
Attributes included from Mixins::HasDocumentation
Instance Method Summary collapse
-
#to_sdl ⇒ String
GraphQL SDL form of the argument.
-
#value_type ⇒ TypeReference
When the argument type is an enum, and we’re configured with different naming for input vs output enums, we need to convert the value type to its input form.
Methods included from Mixins::HasDirectives
#directive, #directives, #directives_sdl
Methods included from Mixins::HasDocumentation
#append_to_documentation, #derived_documentation, #documentation, #formatted_documentation
Methods included from Mixins::VerifiesGraphQLName
Methods included from Mixins::SupportsDefaultValue
Instance Attribute Details
#name ⇒ String (readonly)
Returns name of the argument.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb', line 30 class Argument < Struct.new(:schema_def_state, :parent_field, :name, :original_value_type) prepend Mixins::VerifiesGraphQLName prepend Mixins::SupportsDefaultValue include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |a| "#{a.parent_field.parent_type.name}.#{a.parent_field.name}(#{a.name}: #{a.value_type})" } # @return [String] GraphQL SDL form of the argument def to_sdl "#{formatted_documentation}#{name}: #{value_type}#{default_value_sdl}#{directives_sdl(prefix_with: " ")}" end # When the argument type is an enum, and we're configured with different naming for input vs output enums, # we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than # doing this when `Argument` is instantiated), because the referenced type need not exist when the argument # is defined, and we may not be able to figure out if it's an enum until the type has been defined. So, we # apply this lazily. # # @return [TypeReference] the type of the argument # @see #original_value_type def value_type original_value_type.to_final_form(as_input: true) end end |
#original_value_type ⇒ TypeReference (readonly)
Returns type of the argument, as originally provided.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb', line 30 class Argument < Struct.new(:schema_def_state, :parent_field, :name, :original_value_type) prepend Mixins::VerifiesGraphQLName prepend Mixins::SupportsDefaultValue include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |a| "#{a.parent_field.parent_type.name}.#{a.parent_field.name}(#{a.name}: #{a.value_type})" } # @return [String] GraphQL SDL form of the argument def to_sdl "#{formatted_documentation}#{name}: #{value_type}#{default_value_sdl}#{directives_sdl(prefix_with: " ")}" end # When the argument type is an enum, and we're configured with different naming for input vs output enums, # we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than # doing this when `Argument` is instantiated), because the referenced type need not exist when the argument # is defined, and we may not be able to figure out if it's an enum until the type has been defined. So, we # apply this lazily. # # @return [TypeReference] the type of the argument # @see #original_value_type def value_type original_value_type.to_final_form(as_input: true) end end |
#parent_field ⇒ Field (readonly)
Returns field which has this argument.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb', line 30 class Argument < Struct.new(:schema_def_state, :parent_field, :name, :original_value_type) prepend Mixins::VerifiesGraphQLName prepend Mixins::SupportsDefaultValue include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |a| "#{a.parent_field.parent_type.name}.#{a.parent_field.name}(#{a.name}: #{a.value_type})" } # @return [String] GraphQL SDL form of the argument def to_sdl "#{formatted_documentation}#{name}: #{value_type}#{default_value_sdl}#{directives_sdl(prefix_with: " ")}" end # When the argument type is an enum, and we're configured with different naming for input vs output enums, # we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than # doing this when `Argument` is instantiated), because the referenced type need not exist when the argument # is defined, and we may not be able to figure out if it's an enum until the type has been defined. So, we # apply this lazily. # # @return [TypeReference] the type of the argument # @see #original_value_type def value_type original_value_type.to_final_form(as_input: true) end end |
#schema_def_state ⇒ State (readonly)
Returns state of the schema.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb', line 30 class Argument < Struct.new(:schema_def_state, :parent_field, :name, :original_value_type) prepend Mixins::VerifiesGraphQLName prepend Mixins::SupportsDefaultValue include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |a| "#{a.parent_field.parent_type.name}.#{a.parent_field.name}(#{a.name}: #{a.value_type})" } # @return [String] GraphQL SDL form of the argument def to_sdl "#{formatted_documentation}#{name}: #{value_type}#{default_value_sdl}#{directives_sdl(prefix_with: " ")}" end # When the argument type is an enum, and we're configured with different naming for input vs output enums, # we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than # doing this when `Argument` is instantiated), because the referenced type need not exist when the argument # is defined, and we may not be able to figure out if it's an enum until the type has been defined. So, we # apply this lazily. # # @return [TypeReference] the type of the argument # @see #original_value_type def value_type original_value_type.to_final_form(as_input: true) end end |
Instance Method Details
#to_sdl ⇒ String
Returns GraphQL SDL form of the argument.
38 39 40 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb', line 38 def to_sdl "#{formatted_documentation}#{name}: #{value_type}#{default_value_sdl}#{directives_sdl(prefix_with: " ")}" end |
#value_type ⇒ TypeReference
When the argument type is an enum, and we’re configured with different naming for input vs output enums,
we need to convert the value type to its input form. Note that this intentionally happens lazily (rather than
doing this when Argument
is instantiated), because the referenced type need not exist when the argument
is defined, and we may not be able to figure out if it’s an enum until the type has been defined. So, we
apply this lazily.
50 51 52 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/argument.rb', line 50 def value_type original_value_type.to_final_form(as_input: true) end |