Hi I am new to GraphQL and I am trying to sort my data based on column content. I have an query endpoint where I can send:
query {
user(count:20, firstName:"Foo") {
data {
name
region
birthDate
}
}
}
And the result is an array of 20 users with the first name Foo
. But I want to order them by birthDate
. I already tried so many things, but I just can not figure out. I already tried prepending sort
and orderBy
after the firstName, but I always get errors such as:
{
"errors": [
{
"message": "Unknown argument \"sort\" on field \"user\" of type \"Query\".",
"extensions": {
"category": "graphql"
},
"locations": [
{
"line": 2,
"column": 31
}
]
}
]
}
I am using Laravel Lighthouse as a wapper for GraphQL. I am surprised I could not find any information in regards on how to do this.
My query:
type Query {
user(firstName: String @eq): [User!]! @paginate(type: "paginator" model: "App\\User")
}
type User {
id: ID!
firstName: String!
lastName: String!
birthDate: DateTime!
email: String!
created_at: DateTime!
updated_at: DateTime!
}