Comments (7)
Let me know if you'd like more code. Basically, there is no totalCount field alongside the array of ProjectType coming back in the response. Thanks for this amazing library!
from graphene-django-extras.
A new release will be released soon, with many improvements and new features.
from graphene-django-extras.
Hi @EmiM - I was just investigating this very thing this week and I ended up with the following solution.
DjangoListObjectField actually does filtering and pagination, and returns totalCount. Ironically, DjangoFilterPaginateListField does not. Not sure why.
class ResourceType(DjangoObjectType):
class Meta:
description = "Type definition for resource"
model = Resource
filterset_class = ResourceFilter
class ResourceListType(DjangoListObjectType):
class Meta:
description = "Type definition for resources uses in list queries"
model = Resource
class Query(object):
resource = DjangoObjectField(ResourceType)
resources = DjangoListObjectField(ResourceListType, filterset_class=ResourceFilter, description=('All Resources query'))
I hope this helps!
from graphene-django-extras.
Hello @EmiM and @atomboulian, thanks for asking. Sorry for the delay in responding, but the work has kept me very busy.
Could you show me a complete example where DjangoFilterPaginateListField does not return the totalCount field?
Although I propose you that try the DjangoSerializerType, since it serves both to define the types and to define the mutations based on a serializer.
from graphene-django-extras.
Hi @eamigo86! Sorry for my delay in responding - also busy at work. Here's what we are experiencing:
class Project(AuditTrailModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=255)
ref_id = models.CharField(max_length=50, blank=True, help_text="The client's personal reference identifier.")
project_type = models.CharField(max_length=25, choices=PROJECT_TYPE_CHOICES)
address_line_1 = models.CharField(max_length=255, blank=True)
address_line_2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=100, blank=True)
state_province = models.CharField(max_length=255, blank=True)
postal_code = models.CharField(max_length=10, blank=True)
country = CountryField()
owner = models.ForeignKey(settings.AUTH_USER_MODEL, default=get_current_user, on_delete=models.SET_DEFAULT, related_name="owned_projects")
target_occupancy = models.DateField()
def __str__(self):
return self.name
class ProjectType(DjangoObjectType):
room_count = graphene.Int()
planned_spend = graphene.Float()
budget_variance = graphene.Float()
class Meta:
description = "Type definition for project"
model = Project
filterset_class = ProjectFilter
class Query(object):
project = DjangoObjectField(ProjectType)
projects = DjangoFilterPaginateListField(ProjectType, filterset_class=ProjectFilter, description="Project list query")
from graphene-django-extras.
Is there any solution?
from graphene-django-extras.
any news? is this solved?
from graphene-django-extras.
Related Issues (20)
- Dynamic Schema generation
- Travis rewrite to GitHub Actions HOT 2
- TODO
- Tried installing graphene-django-extras, but get errors about incompatibility HOT 3
- ImportError: cannot import name 'force_text' from 'django.utils.encoding' HOT 1
- Regarding UnionTypes
- Pagination Total Count HOT 7
- When using a model with a UUID Field as ID the update method does not provide a UUID Field HOT 1
- No type registered for model: <model>
- Getting duplicate results on a filter across multiple fields. Cannot add distinct.
- still maintained? HOT 5
- python error: can only concatenate list (not "tuple") to list in __init__.py
- Updates removing other fields if not supplied: Might not be specific to graphene-django-extras
- ImportError: cannot import name 'JSONField' from 'graphene_django.compat'
- AssertionError: Page value for PageGraphqlPagination must be a non-zero value
- Filtering on enum fields returns all results HOT 1
- Logs received not informative
- DjangoListObjectType BigInt Error
- Filter error HOT 2
- Pagination Total Count in DjangoFilterPaginateListField
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphene-django-extras.