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

Getting error 'super' object has no attribute 'items' when performing a create mutation on model with a ForeignKey on itself

Open NwawelAIroume opened this issue 2 years ago • 0 comments

here is my model

class Account(models.Model):
    parent = models.ForeignKey(
        to="backend.Account",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="child_accounts"
    )

here is my mutation

class CreateAccountMutation(DjangoCreateMutation):
    class Meta:
        model = Account
        foreign_key_extras = {"parent": {"type": "auto"}}
        many_to_many_extras = {}
        one_to_one_extras = {}
        many_to_one_extras = {}

grapql data

mutation{
  create_account(input:{code:"RST002"}){
    account{code}
  }
}

[ERROR][2022/May/30 12:42:13][pid-29809][utils.py:155][report_error]>Traceback (most recent call last): File "/.../venv/lib/python3.8/site-packages/promise/promise.py", line 489, in _resolve_from_executor executor(resolve, reject) File "/.../venv/lib/python3.8/site-packages/promise/promise.py", line 756, in executor return resolve(f(*args, **kwargs)) File "/.../venv/lib/python3.8/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise return next(*args, **kwargs) File "/.../venv/lib/python3.8/site-packages/graphene_django_cud/mutations/create.py", line 201, in mutate obj = cls.create_obj( File "/.../venv/lib/python3.8/site-packages/graphene_django_cud/mutations/core.py", line 376, in create_obj obj_id = cls.get_or_create_foreign_obj(field, value, extras, info) File "/.../venv/lib/python3.8/site-packages/graphene_django_cud/mutations/core.py", line 37, in get_or_create_foreign_obj related_obj = cls.create_obj( File "/.../venv/lib/python3.8/site-packages/graphene_django_cud/mutations/core.py", line 285, in create_obj for name, value in super(type(input), input).items(): graphql.error.located_error.GraphQLLocatedError: 'super' object has no attribute 'items'

here is my pip packages with python 3.8.13 graphene 2.1.9 graphene-django 2.15.0 graphene-django-cud 0.10.0 Django 3.2.13

I get similar error on another create mutation on a model with a self ForeignKey

NwawelAIroume avatar May 30 '22 12:05 NwawelAIroume