Skip to content

Commit

Permalink
Merge pull request #12 from bbugh/polymorphic-associations
Browse files Browse the repository at this point in the history
Fixes preload_scope when association is polymorphic
  • Loading branch information
etripier authored May 21, 2018
2 parents add2d25 + 71322c7 commit bdf7fc6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/graphql/preload/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def perform(records)
end

private def preload_scope
scope if scope.try(:klass) == model.reflect_on_association(association).klass
return nil unless scope
reflection = model.reflect_on_association(association)
raise ArgumentError, 'Cannot specify preload_scope for polymorphic associations' if reflection.polymorphic?
scope if scope.try(:klass) == reflection.klass
end

private def validate_association
Expand Down

0 comments on commit bdf7fc6

Please sign in to comment.