Skip to content

Instantly share code, notes, and snippets.

@DennisMartinez
DennisMartinez / association.rb
Created June 14, 2023 12:53 — forked from itkrt2y/association.rb
Association dataloader with graphql-ruby
# official docs: https://graphql-ruby.org/dataloader/sources.html
# app/graphql/sources/association.rb
class Sources::Association < ::GraphQL::Dataloader::Source
def initialize(association_name, scope = nil)
@association_name = association_name
@scope = scope
end
def fetch(records)