Exception: Graphiti::Errors::SingularSideload

Inherits:
Base
  • Object
show all
Defined in:
lib/graphiti/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(sideload, parent_length) ⇒ SingularSideload

Returns a new instance of SingularSideload.



115
116
117
118
# File 'lib/graphiti/errors.rb', line 115

def initialize(sideload, parent_length)
  @sideload = sideload
  @parent_length = parent_length
end

Instance Method Details

#messageObject



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/graphiti/errors.rb', line 120

def message
  <<~MSG
    #{@sideload.parent_resource.class.name}: tried to sideload #{@sideload.name.inspect}, but more than one #{@sideload.parent_resource.model.name} was passed!

    This is because you marked the sideload #{@sideload.name.inspect} with single: true

    You might have done this because the sideload can only be loaded from a :show endpoint, and :index would be too expensive.

    Remove the single: true option to bypass this error.
  MSG
end