module HQ::GraphQL::ObjectAssociation

Public Instance Methods

belongs_to(name, scope = nil, **options, &block) click to toggle source
# File lib/hq/graphql/object_association.rb, line 14
def belongs_to(name, scope = nil, **options, &block)
  add_reflection(name, scope, options, :belongs_to, block)
end
has_many(name, scope = nil, through: nil, **options, &block) click to toggle source
# File lib/hq/graphql/object_association.rb, line 23
def has_many(name, scope = nil, through: nil, **options, &block)
  raise TypeError, "has_many through is unsupported" if through
  add_reflection(name, scope, options, :has_many, block)
end
has_one(name, scope = nil, through: nil, **options, &block) click to toggle source
# File lib/hq/graphql/object_association.rb, line 18
def has_one(name, scope = nil, through: nil, **options, &block)
  raise TypeError, "has_one through is unsupported" if through
  add_reflection(name, scope, options, :has_one, block)
end
reflect_on_association(association) click to toggle source
# File lib/hq/graphql/object_association.rb, line 6
def reflect_on_association(association)
  resource_reflections[association.to_s]&.reflection(model_klass)
end
update(name, &block) click to toggle source
# File lib/hq/graphql/object_association.rb, line 10
def update(name, &block)
  resource_reflections[name.to_s] = UpdatedReflection.new(name, block)
end

Private Instance Methods

add_reflection(name, scope, options, macro, block) click to toggle source
# File lib/hq/graphql/object_association.rb, line 34
def add_reflection(name, scope, options, macro, block)
  resource_reflections[name.to_s] = ResourceReflection.new(name, scope, options, macro, block)
end
resource_reflections() click to toggle source
# File lib/hq/graphql/object_association.rb, line 30
def resource_reflections
  @resource_reflections ||= {}
end