Class: GraphQL::Schema::IntrospectionSystem
- Inherits:
-
Object
- Object
- GraphQL::Schema::IntrospectionSystem
- Defined in:
- lib/graphql/schema/introspection_system.rb
Defined Under Namespace
Classes: PerFieldProxyResolve
Instance Attribute Summary collapse
-
#possible_types ⇒ Object
readonly
Returns the value of attribute possible_types.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#dynamic_field(name:) ⇒ Object
-
#dynamic_fields ⇒ Object
-
#entry_point(name:) ⇒ Object
-
#entry_points ⇒ Object
-
#initialize(schema) ⇒ IntrospectionSystem
constructor
A new instance of IntrospectionSystem.
-
#resolve_late_bindings ⇒ Object
private
The introspection system is prepared with a bunch of LateBoundTypes.
Constructor Details
#initialize(schema) ⇒ IntrospectionSystem
Returns a new instance of IntrospectionSystem.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/graphql/schema/introspection_system.rb', line 7 def initialize(schema) @schema = schema @class_based = !!@schema.is_a?(Class) @built_in_namespace = GraphQL::Introspection @custom_namespace = if @class_based schema.introspection || @built_in_namespace else schema.introspection_namespace || @built_in_namespace end type_defns = [ load_constant(:SchemaType), load_constant(:TypeType), load_constant(:FieldType), load_constant(:DirectiveType), load_constant(:EnumValueType), load_constant(:InputValueType), load_constant(:TypeKindEnum), load_constant(:DirectiveLocationEnum) ] @types = {} @possible_types = {}.tap(&:compare_by_identity) type_defns.each do |t| @types[t.graphql_name] = t @possible_types[t] = [t] end @entry_point_fields = if schema.disable_introspection_entry_points? {} else entry_point_fields = get_fields_from_class(class_sym: :EntryPoints) entry_point_fields.delete('__schema') if schema.disable_schema_introspection_entry_point? entry_point_fields.delete('__type') if schema.disable_type_introspection_entry_point? entry_point_fields end @entry_point_fields.each { |k, v| v.dynamic_introspection = true } @dynamic_fields = get_fields_from_class(class_sym: :DynamicFields) @dynamic_fields.each { |k, v| v.dynamic_introspection = true } end |
Instance Attribute Details
#possible_types ⇒ Object (readonly)
Returns the value of attribute possible_types.
5 6 7 |
# File 'lib/graphql/schema/introspection_system.rb', line 5 def possible_types @possible_types end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
5 6 7 |
# File 'lib/graphql/schema/introspection_system.rb', line 5 def types @types end |
Instance Method Details
#dynamic_field(name:) ⇒ Object
59 60 61 |
# File 'lib/graphql/schema/introspection_system.rb', line 59 def dynamic_field(name:) @dynamic_fields[name] end |
#dynamic_fields ⇒ Object
55 56 57 |
# File 'lib/graphql/schema/introspection_system.rb', line 55 def dynamic_fields @dynamic_fields.values end |
#entry_point(name:) ⇒ Object
51 52 53 |
# File 'lib/graphql/schema/introspection_system.rb', line 51 def entry_point(name:) @entry_point_fields[name] end |
#entry_points ⇒ Object
47 48 49 |
# File 'lib/graphql/schema/introspection_system.rb', line 47 def entry_points @entry_point_fields.values end |
#resolve_late_bindings ⇒ 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.
The introspection system is prepared with a bunch of LateBoundTypes. Replace those with the objects that they refer to, since LateBoundTypes aren’t handled at runtime.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/graphql/schema/introspection_system.rb', line 69 def resolve_late_bindings @types.each do |name, t| if t.kind.fields? t.fields.each do |_name, field_defn| field_defn.type = resolve_late_binding(field_defn.type) end end end @entry_point_fields.each do |name, f| f.type = resolve_late_binding(f.type) end @dynamic_fields.each do |name, f| f.type = resolve_late_binding(f.type) end nil end |