Class: GraphQL::Schema::NonNull
- Includes:
- Member::ValidatesInput
- Defined in:
- lib/graphql/schema/non_null.rb
Overview
Represents a non null type in the schema. Wraps a Schema::Member when it is required. See Schema::Member::TypeSystemHelpers#to_non_null_type
Instance Attribute Summary
Attributes inherited from Wrapper
Instance Method Summary collapse
- #coerce_input(value, ctx) ⇒ Object
- #coerce_result(value, ctx) ⇒ Object
-
#description ⇒ Object
This is for implementing introspection.
-
#graphql_name ⇒ Object
This is for introspection, where it's expected the name will be
null. - #inspect ⇒ Object
-
#kind ⇒ Object
Returns.
-
#list? ⇒ Boolean
Returns.
-
#non_null? ⇒ Boolean
Returns.
- #to_type_signature ⇒ Object
- #validate_input(value, ctx, max_errors: nil) ⇒ Object
Methods included from Member::ValidatesInput
#coerce_isolated_input, #coerce_isolated_result, #valid_input?, #valid_isolated_input?
Methods inherited from Wrapper
#==, #deconstruct_keys, #freeze, #initialize, #unwrap
Methods included from Member::TypeSystemHelpers
#initialize, #to_list_type, #to_non_null_type
Constructor Details
This class inherits a constructor from GraphQL::Schema::Wrapper
Instance Method Details
#coerce_input(value, ctx) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/graphql/schema/non_null.rb', line 66 def coerce_input(value, ctx) # `.validate_input` above is used for variables, but this method is used for arguments if value.nil? raise GraphQL::ExecutionError, "`null` is not a valid input for `#{to_type_signature}`, please provide a value for this argument." end of_type.coerce_input(value, ctx) end |
#coerce_result(value, ctx) ⇒ Object
74 75 76 |
# File 'lib/graphql/schema/non_null.rb', line 74 def coerce_result(value, ctx) of_type.coerce_result(value, ctx) end |
#description ⇒ Object
This is for implementing introspection
79 80 81 |
# File 'lib/graphql/schema/non_null.rb', line 79 def description nil end |
#graphql_name ⇒ Object
This is for introspection, where it's expected the name will be null
62 63 64 |
# File 'lib/graphql/schema/non_null.rb', line 62 def graphql_name nil end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/graphql/schema/non_null.rb', line 47 def inspect "#<#{self.class.name} @of_type=#{@of_type.inspect}>" end |
#kind ⇒ Object
Returns
GraphQL::TypeKinds::NON_NULL
:call-seq:
kind() -> GraphQL::TypeKinds::NON_NULL
19 20 21 |
# File 'lib/graphql/schema/non_null.rb', line 19 def kind GraphQL::TypeKinds::NON_NULL end |
#list? ⇒ Boolean
Returns
Boolean— True if this type wraps a list type
:call-seq:
list?() -> bool
39 40 41 |
# File 'lib/graphql/schema/non_null.rb', line 39 def list? @of_type.list? end |
#non_null? ⇒ Boolean
Returns
true
:call-seq:
non_null?() -> true
29 30 31 |
# File 'lib/graphql/schema/non_null.rb', line 29 def non_null? true end |
#to_type_signature ⇒ Object
43 44 45 |
# File 'lib/graphql/schema/non_null.rb', line 43 def to_type_signature @type_signature ||= -"#{@of_type.to_type_signature}!" end |
#validate_input(value, ctx, max_errors: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/graphql/schema/non_null.rb', line 51 def validate_input(value, ctx, max_errors: nil) if value.nil? result = GraphQL::Query::InputValidationResult.new result.add_problem("Expected value to not be null") result else of_type.validate_input(value, ctx, max_errors: max_errors) end end |