Module: GraphQL::BaseType::HasPossibleTypes
- Included in:
- InterfaceType, UnionType
- Defined in:
- lib/graphql/base_type.rb
Constant Summary collapse
- DEFAULT_RESOLVE_TYPE =
The default implementation of #resolve_type gets ‘object.class.name` and finds a type with the same name
-> (object) { type_name = object.class.name possible_types.find {|t| t.name == type_name} }
Instance Method Summary collapse
- #include?(type) ⇒ Boolean
-
#resolve_type(object) ⇒ GraphQL::ObjectType
Return the implementing type for ‘object`.
- #resolve_type=(new_proc) ⇒ Object
Instance Method Details
#include?(type) ⇒ Boolean
67 68 69 |
# File 'lib/graphql/base_type.rb', line 67 def include?(type) possible_types.include?(type) end |
#resolve_type(object) ⇒ GraphQL::ObjectType
Return the implementing type for ‘object`. The default implementation assumes that there’s a type with the same name as ‘object.class.name`. Maybe you’ll need to override this in your own interfaces!
52 53 54 |
# File 'lib/graphql/base_type.rb', line 52 def resolve_type(object) instance_exec(object, &@resolve_type_proc) end |
#resolve_type=(new_proc) ⇒ Object
63 64 65 |
# File 'lib/graphql/base_type.rb', line 63 def resolve_type=(new_proc) @resolve_type_proc = new_proc || DEFAULT_RESOLVE_TYPE end |