0

Does GraphQL offer built in pagination? Like take first 10 items of collection, offest 2 etc?

I have read here: https://graphql.org/learn/pagination/

On other sites I saw only those examples in which we had to implement these arguments by our own.

Edit: My question is not how to GraphQL: How to implement pagination with graphQL-java? but question - is there built in option for that.

AConsumer
  • 2,461
  • 2
  • 25
  • 33
tryingHard
  • 1,794
  • 4
  • 35
  • 74
  • 1
    No, there is no pagination build in, you have to build yourself. Apollo Client has a section about pagination you can refer https://www.apollographql.com/docs/react/features/pagination.html. It can be offset based, cursor based and etc. – xwlee Jan 22 '19 at 15:55
  • 2
    Possible duplicate of [GraphQL: How to implement pagination with graphQL-java?](https://stackoverflow.com/questions/44574964/graphql-how-to-implement-pagination-with-graphql-java) – Daniel Rearden Jan 22 '19 at 18:21
  • @xwlee thanks - so i need to implement it - thanks – tryingHard Jan 22 '19 at 20:18
  • How you paginate depends on the storage used. A built-in pagination would mean requiring a specific storage type, which would go against GraphQL's universal applicability and would generally be a terrible idea. – kaqqao Feb 13 '19 at 07:20

1 Answers1

2

Its not in build, you need to add input parameters into your api endpoint and then use them to implement pagination. ex- sequelize accepts these parameters as it is and generates query.

yourAPI(filters:yourInputFilters,limit:Int,offset:Int)

Sample with sequelize :

model.findAndCountAll({
            where: filters,
            limit: limit,
            offset: offset
})
Amit Bhoyar
  • 1,007
  • 5
  • 20