Class: GraphQL::Schema::PossibleTypes Private
- Inherits:
-
Object
- Object
- GraphQL::Schema::PossibleTypes
- Defined in:
- lib/graphql/schema/possible_types.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Find the members of a union or interface within a given schema.
(Although its members never change, unions are handled this way to simplify execution code.)
Internally, the calculation is cached. It’s assumed that schema members don’t change after creating the schema!
Instance Method Summary collapse
-
#initialize(schema) ⇒ PossibleTypes
constructor
private
A new instance of PossibleTypes.
-
#possible_types(type_defn) ⇒ Object
private
Constructor Details
#initialize(schema) ⇒ PossibleTypes
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of PossibleTypes
15 16 17 18 19 20 21 |
# File 'lib/graphql/schema/possible_types.rb', line 15 def initialize(schema) @object_types = schema.types.values.select { |type| type.kind.object? } @interface_implementers = Hash.new do |hash, key| hash[key] = @object_types.select { |type| type.interfaces.include?(key) }.sort_by(&:name) end end |
Instance Method Details
#possible_types(type_defn) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/graphql/schema/possible_types.rb', line 23 def possible_types(type_defn) case type_defn when GraphQL::UnionType type_defn.possible_types when GraphQL::InterfaceType @interface_implementers[type_defn] when GraphQL::BaseType [type_defn] else raise "Unexpected possible_types object: #{type_defn}" end end |