Class: GraphQL::Stitching::Composer::ValidateBoundaries

Inherits:
BaseValidator
  • Object
show all
Defined in:
lib/graphql/stitching/composer/validate_boundaries.rb

Instance Method Summary collapse

Instance Method Details

#perform(ctx, composer) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/graphql/stitching/composer/validate_boundaries.rb', line 7

def perform(ctx, composer)
  ctx.schema.types.each do |type_name, type|
    # objects and interfaces that are not the root operation types
    next unless type.kind.object? || type.kind.interface?
    next if ctx.schema.query == type || ctx.schema.mutation == type
    next if type.graphql_name.start_with?("__")

    # multiple subschemas implement the type
    candidate_types_by_location = composer.candidate_types_by_name_and_location[type_name]
    next unless candidate_types_by_location.length > 1

    boundaries = ctx.boundaries[type_name]
    if boundaries&.any?
      validate_as_boundary(ctx, type, candidate_types_by_location, boundaries)
    elsif type.kind.object?
      validate_as_shared(ctx, type, candidate_types_by_location)
    end
  end
end