Giter Site home page Giter Site logo

Comments (6)

bellini666 avatar bellini666 commented on August 17, 2024

Hey @tasiotas ,

I think that it is because the name products is not matching the django model name, so the optimizer doesn't know where to find.

You can try 2 changes in there:

  1. Define a related_name="products on the foreignkey so that it is accessible by self.products.all() instead of self.product_set.all(). Since it matches the name of the field it should work

  2. If you don't want to set a related_name, try to define the field as:

    @gql.django.connection(name="products")
    def product_set(self) -> List["ProductType"]:
        return self.product_set.all()

Let me know if any of those solutions works for you. Otherwise I might need some more info to understand what might be going on there

from strawberry-django-plus.

tasiotas avatar tasiotas commented on August 17, 2024

unfortunately both solutions didn't work. Will try to get you a repro.

Thanks!

from strawberry-django-plus.

bellini666 avatar bellini666 commented on August 17, 2024

unfortunately both solutions didn't work. Will try to get you a repro.

Thanks!

A repro will help a lot to understand how to properly optimize this :)

from strawberry-django-plus.

tasiotas avatar tasiotas commented on August 17, 2024

got the repro. Im new to Poetry, didn't know how to update this lib to latest, so its at 2.4.0
https://github.com/tasiotas/strawberry_debug

without optimizer I have 3 queries, with optimizer I get 6.
Just create some Project and Milestone objects and run this query:

query MyQuery {
  project(name: "one") {
    milestones {
      edges {
        node {
          name
        }
      }
    }
  }
}

from strawberry-django-plus.

bellini666 avatar bellini666 commented on August 17, 2024

Hey @tasiotas ,

I just released a new version, which has a major refactoring of the relay integration by using the official one instead.

Could you check if your issue still happens in that version? I think some of the changes I've made should have fixed this.

from strawberry-django-plus.

tasiotas avatar tasiotas commented on August 17, 2024

unfortunately, its still the same behavior in v3

from strawberry-django-plus.

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.