graphql-php
graphql-php copied to clipboard
How would I return a list of objects with total records
Lets say I have a list of records I can return based on some value. And there are so many records I want to paginate over them. But the front end wants to make a nice navigation of page 1, 2, etc...
If I design a schema like this
type Orders{
id: ID
user_id: Int
date: String
...
}
and I have a query like
userOrders(user_id: Int!, limit: Int, offset:: Int): [Orders]
I would like to return a result like
{
data: {
userOrders: [
{ id:1,user_id:1,date:"2021-04-01",...},
{ id:2,user_id:1,date:"2021-04-11",...},
...
]
},
total: 124
}
is there a way to do this, or would I need to modify my type to include a "total" field?