Giter Site home page Giter Site logo

Comments (7)

atomboulian avatar atomboulian commented on August 13, 2024 1

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.

eamigo86 avatar eamigo86 commented on August 13, 2024 1

A new release will be released soon, with many improvements and new features.

from graphene-django-extras.

atomboulian avatar atomboulian commented on August 13, 2024

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.

eamigo86 avatar eamigo86 commented on August 13, 2024

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.

atomboulian avatar atomboulian commented on August 13, 2024

Hi @eamigo86! Sorry for my delay in responding - also busy at work. Here's what we are experiencing:

screen shot 2018-07-18 at 12 17 30 pm

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.

ldsad7 avatar ldsad7 commented on August 13, 2024

Is there any solution?

from graphene-django-extras.

digitalw avatar digitalw commented on August 13, 2024

any news? is this solved?

from graphene-django-extras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.