Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NwawelAIroume opened this issue May 30, 2022 · 0 comments

Comments

@NwawelAIroume
Copy link

NwawelAIroume commented May 30, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant