2

In graphene-django I have a pagination limit set in my settings.py file like below.

GRAPHENE = {
    'RELAY_CONNECTION_MAX_LIMIT': 150,
}

Let's say a particular query returns 200 items (I don't know beforehand) and I want to display all of this data on a graph. How do I stop graphene from paginating it when returning the results?

chidimo
  • 2,684
  • 3
  • 32
  • 47

1 Answers1

3

You can override the max_limit argument for every DjangoFilterConnectionField individually. Setting this to None basically disables the limiting behaviour.

Suppose you have the following query for a UserNode class:

class UserQuery(graphene.ObjectType):
    all_users = DjangoFilterConnectionField(UserNode, max_limit=None)

The max_limit parameter will internally be processed by the DjangoConnectionClass which provides the limiting behaviour via the mentioned setting RELAY_CONNECTION_MAX_LIMIT

Beware though that this might lead to drastic performance issues in case of very large or expensive queries. Personally I would probably go for either a very high but still resonable limit depending on your data or preferrably look into implementing proper pagination behaviour on the client side.

Ole
  • 41
  • 3
  • Thanks for the suggestion. But it does seem to me that the best course of action is to create a separate endpoint that doesn't go through the connection class. – chidimo Feb 22 '21 at 20:47
  • Does that not kind of work around the basic idea of GraphQL? Especially in a `relay` environment where you most probably want to have a uniform api with `edges` and `nodes` etc. – Ole Feb 23 '21 at 19:45
  • It does. But I'll stick with that for now until I'm able to find what I'm looking for. – chidimo Feb 23 '21 at 21:30