Class: GraphQL::DSL::VariableDefinition
- Inherits:
-
Object
- Object
- GraphQL::DSL::VariableDefinition
- Defined in:
- lib/graphql/dsl/nodes/containers/variable_definition.rb
Overview
Container for variable definition
Instance Attribute Summary collapse
-
#default ⇒ Object?
readonly
Default value of variable.
-
#directives ⇒ Array<Directive>
readonly
List of directives.
-
#type ⇒ String, ...
readonly
Variable type.
Class Method Summary collapse
-
.from(value) ⇒ VariableDefinition
Create variable definition container from argument value.
Instance Method Summary collapse
-
#initialize(type, default = UNDEFINED, directives = []) ⇒ VariableDefinition
constructor
Create variable definition container.
Constructor Details
#initialize(type, default = UNDEFINED, directives = []) ⇒ VariableDefinition
Create variable definition container
26 27 28 29 30 31 32 |
# File 'lib/graphql/dsl/nodes/containers/variable_definition.rb', line 26 def initialize(type, default = UNDEFINED, directives = []) raise Error, 'Variable type must be specified' if type.nil? || type.empty? @type = type @default = default @directives = directives.map { |directive| Directive.from(directive) } end |
Instance Attribute Details
#default ⇒ Object? (readonly)
Returns default value of variable.
14 15 16 |
# File 'lib/graphql/dsl/nodes/containers/variable_definition.rb', line 14 def default @default end |
#directives ⇒ Array<Directive> (readonly)
Returns list of directives.
18 19 20 |
# File 'lib/graphql/dsl/nodes/containers/variable_definition.rb', line 18 def directives @directives end |
#type ⇒ String, ... (readonly)
Returns variable type.
10 11 12 |
# File 'lib/graphql/dsl/nodes/containers/variable_definition.rb', line 10 def type @type end |
Class Method Details
.from(value) ⇒ VariableDefinition
Create variable definition container from argument value
41 42 43 44 45 46 47 48 |
# File 'lib/graphql/dsl/nodes/containers/variable_definition.rb', line 41 def from(value) case value when VariableDefinition then value when Symbol, String then new(value) else raise Error.new('Unsupported format of variable definition', class: value.class.name, value: value) end end |