Class: GraphQL::Query::TypeResolver
- Inherits:
-
Object
- Object
- GraphQL::Query::TypeResolver
- Defined in:
- lib/graphql/query/type_resolver.rb
Overview
Given an object, a type name (from the query) and a type object, Return the type that should be used for ‘object` or Return `nil` if it’s a mismatch
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(target, child_type, parent_type) ⇒ TypeResolver
constructor
A new instance of TypeResolver.
Constructor Details
#initialize(target, child_type, parent_type) ⇒ TypeResolver
Returns a new instance of TypeResolver.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/graphql/query/type_resolver.rb', line 6 def initialize(target, child_type, parent_type) @type = if child_type.nil? nil elsif parent_type.kind.union? parent_type.resolve_type(target) elsif child_type.kind.union? && child_type.include?(parent_type) parent_type elsif child_type.kind.interface? child_type.resolve_type(target) elsif child_type == parent_type parent_type else nil end end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/graphql/query/type_resolver.rb', line 5 def type @type end |