eamigo86 / graphene-django-extras

Extras functionalities for Graphene-Django
MIT License
417 stars 108 forks source link

No type registered for model: <model> #186

Open lautarodapin opened 2 years ago

lautarodapin commented 2 years ago

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()