Exception: GraphQL::Query::VariableValidationError
- Inherits:
-
ExecutionError
- Object
- StandardError
- Error
- ExecutionError
- GraphQL::Query::VariableValidationError
- Defined in:
- lib/graphql/query/variable_validation_error.rb
Instance Attribute Summary collapse
-
#validation_result ⇒ Object
Returns the value of attribute validation_result.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from ExecutionError
#ast_node, #extensions, #options, #path
Instance Method Summary collapse
-
#initialize(variable_ast, type, value, validation_result, msg: nil) ⇒ VariableValidationError
constructor
A new instance of VariableValidationError.
- #to_h ⇒ Object
Constructor Details
#initialize(variable_ast, type, value, validation_result, msg: nil) ⇒ VariableValidationError
Returns a new instance of VariableValidationError.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/graphql/query/variable_validation_error.rb', line 7 def initialize(variable_ast, type, value, validation_result, msg: nil) @value = value @validation_result = validation_result msg ||= "Variable $#{variable_ast.name} of type #{type.to_type_signature} was provided invalid value" if problem_fields.any? msg += " for #{problem_fields.join(", ")}" end super(msg) self.ast_node = variable_ast end |
Instance Attribute Details
#validation_result ⇒ Object
Returns the value of attribute validation_result.
5 6 7 |
# File 'lib/graphql/query/variable_validation_error.rb', line 5 def validation_result @validation_result end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/graphql/query/variable_validation_error.rb', line 5 def value @value end |
Instance Method Details
#to_h ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/graphql/query/variable_validation_error.rb', line 21 def to_h # It is possible there are other extension items in this error, so handle # a one level deep merge explicitly. However beyond that only show the # latest value and problems. super.merge({ "extensions" => { "value" => value, "problems" => validation_result.problems }}) do |key, oldValue, newValue| if oldValue.respond_to?(:merge) oldValue.merge(newValue) else newValue end end end |