diff options
Diffstat (limited to 'app/graphql/loaders/base_loader.rb')
-rw-r--r-- | app/graphql/loaders/base_loader.rb | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/app/graphql/loaders/base_loader.rb b/app/graphql/loaders/base_loader.rb index c32c4daa91a..aad435ea09b 100644 --- a/app/graphql/loaders/base_loader.rb +++ b/app/graphql/loaders/base_loader.rb @@ -1,8 +1,10 @@ # Helper methods for all loaders -class Loaders::BaseLoader < GraphQL::Batch::Loader - # Convert a class method into a resolver proc. The method should follow the - # (obj, args, ctx) calling convention - class << self +module Loaders::BaseLoader + extend ActiveSupport::Concern + + class_methods do + # Convert a class method into a resolver proc. The method should follow the + # (obj, args, ctx) calling convention def [](sym) resolver = method(sym) raise ArgumentError.new("#{self}.#{sym} is not a resolver") unless resolver.arity == 3 @@ -10,15 +12,4 @@ class Loaders::BaseLoader < GraphQL::Batch::Loader resolver end end - - # Fulfill all keys. Pass a block that converts each result into a key. - # Any keys not in results will be fulfilled with nil. - def fulfill_all(results, keys, &key_blk) - results.each do |result| - key = yield result - fulfill(key, result) - end - - keys.each { |key| fulfill(key, nil) unless fulfilled?(key) } - end end |