I am fetching dynamic data using Graphene-Django Relay specification.
import graphene
from graphene_django.types import DjangoObjectType
from graphene_django.fields import DjangoConnectionField
from . import models
class PostType(DjangoObjectType):
class Meta:
model = models.Post
interfaces = (graphene.Node, )
class Query(graphene.ObjectType):
post = graphene.Field(PostType)
posts = DjangoConnectionField(PostType)
def resolve_posts(self, info, **kwargs):
return models.Post.objects.order_by('-score', '-id')
When I add a new post after fetching cursors and data, cursors change. In other words, the cursor that was pointing to the exact offset of data does not point that data any longer. It points a new, different data. Thereby, I cannot implement a cursor-based pagination by using:
query fetchPosts ($cursor) {
posts(first: 20, after: $cursor)...
}
Because cursor changes as data changes, it is no different than traditional offset-based-pagination. Is there something I am missing? What I want for the cursor is not to change. Like this article:
https://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/
How should I make the cursor point the same data that changes dynamically?