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

No type registered for model: <model>

Open lautarodapin opened this issue 1 year ago • 0 comments

I had an issue that i can't fix. I'm trying to use this package together with graphene-django defining types with the extra package and using DjangoModelFormMutation from the graphene-django package. But for some reason the types that I register using the extras class are not present for the other package.

image

Here is an example

# models.py
class Category(models.Model):
    name = models.CharField(max_length=16)

# forms.py
from django import forms
from graphene_django.forms.mutation import DjangoModelFormMutation

class CategoryForm(forms.ModelForm):
   class Meta:
        model = Category
        fields = ['name']

# schema.py
import graphene
from graphene_django_extras import DjangoObjectType
from .models import Category
from .forms import CategoryForm

class CategoryType(DjangoObjectType):
    class Meta:
        model = Category

class CreateCategoryMutation(DjangoModelFormMutation):
    class Meta:
        form_class = CategoryForm       # <----- For some reason `CategoryType` is not register for the graphene_django package


class Mutation(graphene.Mutation):
     create_category = CreateCategoryMutation.Field()

lautarodapin avatar Aug 01 '22 12:08 lautarodapin