NoMethodError when page is not a hash
Request:
/some_controller?limit=10&page=1
Error:
undefined method `each_pair' for "1":String
Did you mean? each_char
The error comes from here:
# graphiti/query.rb
def pagination
@pagination ||= begin
{}.tap do |hash|
(@params[:page] || {}).each_pair do |name, value|
Would you accept a pull request to handle that gracefully?
To throw a better error? Absolutely!
Which kind of error should we throw? Some kind of schema error?
I think a Graphiti::Errors::InvalidRequest. In fact this is what we throw for writes, and have validator classes for writes https://github.com/graphiti-api/graphiti/tree/master/lib/graphiti/request_validators
Ideally we'd do the something similar for reads (already runs through a validator and does nothing actually - https://github.com/graphiti-api/graphiti/blob/master/lib/graphiti/request_validators/validator.rb#L17)