Sure you can implement it yourself. All you need is a Result object that returns both result and a set of items:
class CommentsPage(graphene.ObjectType):
cursor = graphene.String()
comments = graphene.List(Comment)
comments = graphene.Field(CommentsPage, cursor=graphene.Argument(String))
@graphene.resolve_only_args
def resolve_comments(self, cursor=None):
comments, new_cursor = ... fetch from DB according to cursor value ...
return CommentsPage(
cursor=new_cursor,
comments=comments
)
@ekampf Is there any tradeoff with this approach as compared to relay style cursor pagination ? I am trying to understand the same, your insight will be greatly helpful.
@syrusakbary I have usecase , any insight is very helpful , consider an api that returns paginated response which are flat(unlike relay style nodes/edges) , performance is my top priority still I would want to have flat response, is it possible to somehow efficiently parse relay style response to flat style. even if you can point me to some resource that will me make this decision, it will be very helpful .. what would you do for this use case ?
@rjdp the tradeoff is that this schema is simpler and easier to use (and implement).
But, you can't use it with Relay. If you're not using Relay this could do just fine for you...
Thanks for the help 馃憤
@rjdp I guess you can close the issue?
Most helpful comment
Sure you can implement it yourself. All you need is a Result object that returns both result and a set of items: