Exception: GraphQL::Schema::Enum::UnresolvedValueError
- Defined in:
- lib/graphql/schema/enum.rb
Overview
This is raised when either:
- A resolver returns a value which doesn’t match any of the enum’s configured values;
- Or, the resolver returns a value which matches a value, but that value’s
authorized?
check returns false.
In either case, the field should be modified so that the invalid value isn’t returned.
GraphQL::Schema::Enum subclasses get their own subclass of this error, so that bug trackers can better show where they came from.
Instance Method Summary collapse
-
#initialize(value:, enum:, context:, authorized:) ⇒ UnresolvedValueError
constructor
A new instance of UnresolvedValueError.
Constructor Details
#initialize(value:, enum:, context:, authorized:) ⇒ UnresolvedValueError
Returns a new instance of UnresolvedValueError.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/graphql/schema/enum.rb', line 34 def initialize(value:, enum:, context:, authorized:) = if == false ", but this value was unauthorized. Update the field or resolver to return a different value in this case (or return `nil`)." else ", but this isn't a valid value for `#{enum.graphql_name}`. Update the field or resolver to return one of `#{enum.graphql_name}`'s values instead." end = if (cp = context[:current_path]) && (cf = context[:current_field]) "`#{cf.path}` returned `#{value.inspect}` at `#{cp.join(".")}`#{}" else "`#{value.inspect}` was returned for `#{enum.graphql_name}`#{}" end super() end |