Method: GraphQL::Schema::Union.assign_type_membership_object_type

Defined in:
lib/graphql/schema/union.rb

.assign_type_membership_object_type(object_type) ⇒ 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.

Update a type membership whose .object_type is a string or late-bound type so that the type membership's .object_type is the given object_type. (This is used for updating the union after the schema as lazily loaded the union member.)



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/graphql/schema/union.rb', line 55

def assign_type_membership_object_type(object_type)
  assert_valid_union_member(object_type)
  type_memberships.each { |tm|
    possible_type = tm.object_type
    if possible_type.is_a?(String) && (possible_type == object_type.name)
      # This is a match of Ruby class names, not graphql names,
      # since strings are used to refer to constants.
      tm.object_type = object_type
    elsif possible_type.is_a?(LateBoundType) && possible_type.graphql_name == object_type.graphql_name
      tm.object_type = object_type
    end
  }
  nil
end