Class: GraphQL::Schema::Traversal Private

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/schema/traversal.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.

Visit the members of this schema and build up artifacts for runtime.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema, introspection: true) ⇒ Traversal

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 Traversal.

Parameters:


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
46
47
48
49
# File 'lib/graphql/schema/traversal.rb', line 21

def initialize(schema, introspection: true)
  @schema = schema
  @introspection = introspection
  built_in_insts = [
    GraphQL::Relay::ConnectionInstrumentation,
    GraphQL::Relay::EdgesInstrumentation,
    GraphQL::Relay::Mutation::Instrumentation,
  ]

  if schema.query_execution_strategy != GraphQL::Execution::Interpreter
    built_in_insts << GraphQL::Schema::Member::Instrumentation
  end

  @field_instrumenters =
    schema.instrumenters[:field] +
      built_in_insts +
      schema.instrumenters[:field_after_built_ins]

  # These fields have types specified by _name_,
  # So we need to inspect the schema and find those types,
  # then update their references.
  @late_bound_fields = []
  @type_map = {}
  @instrumented_field_map = Hash.new { |h, k| h[k] = {} }
  @type_reference_map = Hash.new { |h, k| h[k] = [] }
  @union_memberships = Hash.new { |h, k| h[k] = [] }
  visit(schema, schema, nil)
  resolve_late_bound_fields
end

Instance Attribute Details

#instrumented_field_mapHash<String => Hash<String => GraphQL::Field>> (readonly)

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:


11
12
13
# File 'lib/graphql/schema/traversal.rb', line 11

def instrumented_field_map
  @instrumented_field_map
end

#type_mapHash<String => GraphQL::BaseType] (readonly)

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 Hash GraphQL::BaseType].

Returns:


8
9
10
# File 'lib/graphql/schema/traversal.rb', line 8

def type_map
  @type_map
end

#type_reference_mapHash<String => Array<GraphQL::Field || GraphQL::Argument || GraphQL::Directive>] (readonly)

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 Hash Array].

Returns:


14
15
16
# File 'lib/graphql/schema/traversal.rb', line 14

def type_reference_map
  @type_reference_map
end

#union_membershipsHash<String => Array<GraphQL::BaseType>] (readonly)

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 Hash ArrayGraphQL::BaseType].

Returns:


17
18
19
# File 'lib/graphql/schema/traversal.rb', line 17

def union_memberships
  @union_memberships
end