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, ctx) { type_name = object.class.name ctx.schema.possible_types(self).find {|t| t.name == type_name} }
Instance Method Summary collapse
-
#resolve_type(object, ctx) ⇒ GraphQL::ObjectType
Return the implementing type for ‘object`.
- #resolve_type=(new_proc) ⇒ Object
Instance Method Details
#resolve_type(object, ctx) ⇒ 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!
59 60 61 62 |
# File 'lib/graphql/base_type.rb', line 59 def resolve_type(object, ctx) ensure_defined instance_exec(object, ctx, &(@resolve_type_proc || DEFAULT_RESOLVE_TYPE)) end |
#resolve_type=(new_proc) ⇒ Object
71 72 73 |
# File 'lib/graphql/base_type.rb', line 71 def resolve_type=(new_proc) @resolve_type_proc = new_proc || DEFAULT_RESOLVE_TYPE end |