Class: GraphQL::Schema::BuildFromDefinition::Builder::TypeLinks

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/schema/build_from_definition.rb

Overview

References between types in this document, recorded while they're built.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ TypeLinks

Returns a new instance of TypeLinks.



329
330
331
332
333
# File 'lib/graphql/schema/build_from_definition.rb', line 329

def initialize
  @references = {}.compare_by_identity
  @arguments = []
  @complete = true
end

Instance Attribute Details

#arguments ⇒ Object (readonly)

Returns the value of attribute arguments.



338
339
340
# File 'lib/graphql/schema/build_from_definition.rb', line 338

def arguments
  @arguments
end

#references ⇒ Object (readonly)

Hash of type => Array of the fields and arguments that use it (no duplicates, since each one is added once)



336
337
338
# File 'lib/graphql/schema/build_from_definition.rb', line 336

def references
  @references
end

Instance Method Details

#add_argument(argument, argument_type) ⇒ Object



349
350
351
352
# File 'lib/graphql/schema/build_from_definition.rb', line 349

def add_argument(argument, argument_type)
  @arguments << argument
  add_reference(argument, argument_type)
end

#add_reference(member, member_type) ⇒ Object



354
355
356
357
358
359
360
361
362
# File 'lib/graphql/schema/build_from_definition.rb', line 354

def add_reference(member, member_type)
  member_type = member_type.unwrap
  if member_type.is_a?(Schema::LateBoundType)
    # The generic traversal will raise an error for this
    incomplete!
  else
    (@references[member_type] ||= []) << member
  end
end

#complete? ⇒ Boolean

True if everything was recorded, so the generic traversal isn't needed

Returns:

  • (Boolean)


341
342
343
# File 'lib/graphql/schema/build_from_definition.rb', line 341

def complete?
  @complete
end

#incomplete! ⇒ Object



345
346
347
# File 'lib/graphql/schema/build_from_definition.rb', line 345

def incomplete!
  @complete = false
end