Reputation: 10719
I'm using DjangoFilterConnectionField with a django-graphene and django-filter. and I'd like to know if it's possible to get all the records via a query?
Consider the following code:
class Query(graphene.AbstractType):
txt = graphene.Field(LocalizedTxtType)
all_txts = DjangoFilterConnectionField(LocalizedLocalizedTxtType)
How can I get all records with no filter (i.e. allTxts) ? Do I need to add a resolve_all myself , or does DjangoFilterConnectionField provide a way to query for all records?
Upvotes: 2
Views: 1514
Reputation: 36
Duplicate of How do I change relay connection limit in graphene django
By default the DjangoFilterConnectionField "max_limit" is set to 100. If set to None, it will fetch all records:
all_txts = DjangoFilterConnectionField(LocalizedLocalizedTxtType, max_limit=None)
Upvotes: 2
Reputation: 34286
Are you looking for getting all of the fields within a model as follows?
from graphene_django import DjangoObjectType
from model.path import Model
class ModelType(DjangoObjectType):
class Meta:
model = Model
fields = "__all__"
class Query(graphene.ObjectType):
models = graphene.List(MapType)
def resolve_models(self, info):
return Model.objects.all()
Upvotes: 0