MichalLytek / MichalLytek/type-graphql
Pagination model
@MichalLytek is already working on this.
Since Oct 24, 2018.
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 672
- PR merge metrics
- No merged PRs in 30d
Description
I think it might be nice to have a pagination model that will allow to create universal resolvers, types definitions, etc. for collections.
For now I am going to expose two types of models:
Simple pagination
Like with standard rest apis - only offset (skip), limit (take), count and items.
@Resolver()
class SampleResolver {
@Query(returns => [Type])
paginatedQuery(
@PaginationArgs() { offset, limit }: PaginationArgs,
): PaginationResponse<Type> {
// ...
return [data, count];
}
}
By using @PaginationArgs() it will detect that the query is being paginated, so the returned tuple [TData, number] will be converted into an object with page info (hasNextPage, etc.), data and total properties.
Relay connection
Using cursor model, which is better for highly dynamic collections:
https://facebook.github.io/relay/graphql/connections.htm
API - TBD.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.