I am trying to retrieve only 5 first records from my query and I saw that there was the keyword "first" to do that onGraphQL. I tried and it says undefined argument. Since it is a GraphQL keyword why it does not recognize it? I am using Ruby on Rails as back-end.
This is the query
{
users(first: 5) {
id
firstName
}
}
and here is my resolver
module Queries
class User< Queries::BaseQuery
argument :id, ID, required: false
description 'Return current user'
type [OutputTypes::UserType], null: false
def resolve(id: nil)
if id
::User.where(id: id)
else
::User.all
end
end
end
end
When I try to run the query I get this error:
{
"errors": [
{
"message": "Field 'users' doesn't accept argument 'first'",
"locations": [
{
"line": 2,
"column": 9
}
],
"path": [
"query",
"users",
"first"
],
"extensions": {
"code": "argumentNotAccepted",
"name": "users",
"typeName": "Field",
"argumentName": "first"
}
}
]
}