Class: GraphQL::Language::Nodes::VariableDefinition
- Inherits:
-
AbstractNode
- Object
- AbstractNode
- GraphQL::Language::Nodes::VariableDefinition
- Defined in:
- lib/graphql/language/nodes.rb
Overview
An operation-level query variable
Constant Summary
Constants inherited from AbstractNode
Instance Attribute Summary collapse
-
#default_value ⇒ Object
readonly
Returns.
-
#directives ⇒ Object
(also: #children)
readonly
: Array.
-
#name ⇒ Object
readonly
Returns.
-
#type ⇒ Object
readonly
Returns.
Attributes inherited from AbstractNode
Class Method Summary collapse
-
.from_a(filename, line, col, name, type, default_value, directives, comment: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Instance Method Summary collapse
-
#initialize(name: nil, type: nil, default_value: nil, directives: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) ⇒ VariableDefinition
constructor
: (?name: untyped, ?type: untyped, ?default_value: untyped, ?directives: Array, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped, ?definition_pos: Integer?) -> void.
- #marshal_dump ⇒ Object
- #marshal_load(values) ⇒ Object
- #merge_directive(**node_opts) ⇒ Object
- #scalars ⇒ Object
- #visit_method ⇒ Object
Methods inherited from AbstractNode
#==, #children_method_name, children_of_type, #col, #definition_line, #delete_child, inherited, #initialize_copy, #line, #merge, #position, #replace_child, #to_query_string
Constructor Details
#initialize(name: nil, type: nil, default_value: nil, directives: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) ⇒ VariableDefinition
: (?name: untyped, ?type: untyped, ?default_value: untyped, ?directives: Array, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped, ?definition_pos: Integer?) -> void
969 970 971 972 973 974 975 976 977 978 979 980 |
# File 'lib/graphql/language/nodes.rb', line 969 def initialize(name: nil, type: nil, default_value: nil, directives: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) @line = line @col = col @pos = pos @filename = filename @source = source @name = name @type = type @default_value = default_value @directives = directives.freeze @definition_pos = definition_pos end |
Instance Attribute Details
#default_value ⇒ Object (readonly)
Returns
String, Integer, Float, Boolean, Array, NullValue— A Ruby value to use if no other value is provided : untyped
953 954 955 |
# File 'lib/graphql/language/nodes.rb', line 953 def default_value @default_value end |
#directives ⇒ Object (readonly) Also known as: children
: Array
960 961 962 |
# File 'lib/graphql/language/nodes.rb', line 960 def directives @directives end |
#name ⇒ Object (readonly)
Returns
String— The identifier for this variable, without$: String
941 942 943 |
# File 'lib/graphql/language/nodes.rb', line 941 def name @name end |
#type ⇒ Object (readonly)
Returns
TypeName, NonNullType, ListType— The expected type of this value
: TypeName | ListType | NonNullType
947 948 949 |
# File 'lib/graphql/language/nodes.rb', line 947 def type @type end |
Class Method Details
.from_a(filename, line, col, name, type, default_value, directives, comment: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
982 983 984 |
# File 'lib/graphql/language/nodes.rb', line 982 def self.from_a(filename, line, col, name, type, default_value, directives, comment: nil) # rubocop:disable Metrics/ParameterLists self.new(filename: filename, line: line, col: col, name: name, type: type, default_value: default_value, directives: directives) end |
Instance Method Details
#marshal_dump ⇒ Object
986 987 988 989 990 991 992 993 994 995 |
# File 'lib/graphql/language/nodes.rb', line 986 def marshal_dump [ line, col, # use methods here to force them to be calculated @filename, @name, @type, @default_value, @directives, ] end |
#marshal_load(values) ⇒ Object
997 998 999 |
# File 'lib/graphql/language/nodes.rb', line 997 def marshal_load(values) @line, @col, @filename, @name, @type, @default_value, @directives = values end |
#merge_directive(**node_opts) ⇒ Object
962 963 964 |
# File 'lib/graphql/language/nodes.rb', line 962 def merge_directive(**node_opts) merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)]) end |
#scalars ⇒ Object
955 956 957 |
# File 'lib/graphql/language/nodes.rb', line 955 def scalars @scalars ||= [@name, @type, @default_value].freeze end |
#visit_method ⇒ Object
933 934 935 |
# File 'lib/graphql/language/nodes.rb', line 933 def visit_method :on_variable_definition end |