graphene-django-optimizer icon indicating copy to clipboard operation
graphene-django-optimizer copied to clipboard

Is Django 4.1.5 supported?

Open dharani7998 opened this issue 1 year ago • 1 comments

Hi, I was trying out the query optimizer for my POC but even a simple query returned an error.

class ProductType(DjangoObjectType):
    class Meta:
        model = Product
        fields = ALL_FIELDS


class Query(graphene.ObjectType):
    products = graphene.List(ProductType)

    def resolve_products(root, info):
        return gql_optimizer.query(Product.objects.all(), info)
{
  "errors": [
    {
      "message": "There is no current event loop in thread 'Thread-1 (process_request_thread)'.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "products"
      ]
    }
  ],
  "data": {
    "products": null
  }
}

And can you also please add an example of how to use it with the relay interface? When I tried it, it returned an error.

class ProductNode(DjangoObjectType):
    class Meta:
        model = Product
        filter_fields = "__all__"
        interfaces = (relay.Node,)


class Query(graphene.ObjectType):
    products = DjangoFilterConnectionField(ProductNode)

    def resolve_products(root, info):
        return gql_optimizer.query(Product.objects.all(), info)


{
  "errors": [
    {
      "message": "Cannot return null for non-nullable field BrandNodeConnection.edges.",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ],
      "path": [
        "brands",
        "edges"
      ]
    }
  ],
  "data": {
    "brands": null
  }
}

python==3.10.8

Django==4.1.5 graphene==3.2.1 graphene-django==3.0.0 graphene-django-optimizer==0.9.1

dharani7998 avatar Jan 26 '23 22:01 dharani7998