Exception: GraphSQL::AliasedAssociationError
- Inherits:
-
StandardError
- Object
- StandardError
- GraphSQL::AliasedAssociationError
- Defined in:
- lib/graphsql/aliased_association_error.rb
Overview
Raised by Resolver#nested_associations when a query requests the same
underlying AR association under two different GraphQL field names (e.g.
owner/employer both mapped to belongs_to :organization), both
resolving to a nestable (to:-mapped) target. Both aliases share one
association proxy on the record, and ActiveRecord::Associations::Preloader
skips an association it's already marked loaded — so only the first
alias's column-limited scope actually takes effect, and the second
alias's requested fields silently go missing (up to and including a
MissingAttributeError). Raising here turns that into a loud, immediate
failure instead of a silent one.
Class Method Summary collapse
Class Method Details
.for_duplicate(type:, association:, fields:) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/graphsql/aliased_association_error.rb', line 15 def self.for_duplicate(type:, association:, fields:) new("#{type} maps association `#{association}` under multiple requested GraphQL fields " \ "(#{fields.map(&:inspect).join(', ')}) — GraphQL.resolve can only apply one column-limited " \ "preload scope per underlying association per query. Request only one of these fields, or " \ "don't map `#{association}` under more than one GraphQL field name.") end |