According to the documentation this library has two goals:
- Automate the pagination between two entities that share a relationship in TypeORM (more ORM support coming soon)
- Make it easy and boilerplate-free to implement your own pagination logic, by taking care of all the type generating and exposing easy to use APIs
I'm trying to just implement pagination on my user model without any relationships. Is that even possible?
This is what I've tried:
@Resolver(of => UserModel)
export class User {
constructor(
@InjectRepository(UserModel)
private readonly userRepository: Repository<UserModel>,
) {
}
@RelayedQuery(() => UserModel)
async users(
@RelayLimitOffset() {limit, offset}: RelayLimitOffsetArgs
): Promise<[UserModel[], number]> {
return this.userRepository.findAndCount({
skip: offset,
take: limit
})
}
And the stacktrace I'm getting:
"Error: Cannot return null for non-nullable field Query.users.",
" at completeValue (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:560:13)",
" at completeValueCatchingError (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:495:19)",
" at resolveField (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:435:10)",
" at executeFields (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:275:18)",
" at executeOperation (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:219:122)",
" at executeImpl (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:104:14)",
" at Object.execute (/Users/danklasson/Code/analyze-jestsj/node_modules/graphql/execution/execute.js:64:35)",
" at /Users/danklasson/Code/analyze-jestsj/node_modules/apollo-server-core/dist/requestPipeline.js:246:46",
" at Generator.next (<anonymous>)",
" at /Users/danklasson/Code/analyze-jestsj/node_modules/apollo-server-core/dist/requestPipeline.js:8:71"
It's taken straight from the documentation. But I had to switch the order of the type declaration of the return Promise to get it to compile.
What am I missing here?
According to the documentation this library has two goals:
I'm trying to just implement pagination on my
usermodel without any relationships. Is that even possible?This is what I've tried:
And the stacktrace I'm getting:
It's taken straight from the documentation. But I had to switch the order of the type declaration of the return Promise to get it to compile.
What am I missing here?