I am using @paginator
directive on my query and my client wants to get all records of posts from the query. This is my code:
posts: [Post!]! @paginate
I tested this querys:
posts(first:0) {id} #works but don't get all records
posts(first:-1) {id} #error
One way was to get all records was to use the value of total
inside the paginatorInfo
and make a new query with that value on the first:
.
posts(first:0) {
paginatorInfo {
total
}
}
For optimization making 2 querys to get all records is very bad.
The best approach I got was to make a new query (now having two querys for posts with different directives and names) like:
allPosts: [Post!]! @all
Other approaches but not so clean:
(first: 100000000)
(the int
is 32 bits so has a limit).@paginantor
to a @field(resolver:)
and do pagination with pure php.