mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-25 02:54:06 +03:00
9a773b9d7b
* Use ruff in pre-commit * Add pyupgrade * Add isort * Add bugbear * Fix B015 Pointless comparison * Fix B026 * B018 false positive * Remove flake8 and isort config from setup.cfg * Remove black and flake8 from dev dependencies * Update black * Show list of fixes applied with autofix on * Fix typo * Add C4 flake8-comprehensions * Add ruff to dev dependencies * Fix up
38 lines
922 B
Python
38 lines
922 B
Python
# https://github.com/graphql-python/graphene-django/issues/520
|
|
|
|
|
|
from django import forms
|
|
from rest_framework import serializers
|
|
|
|
import graphene
|
|
|
|
from ...forms.mutation import DjangoFormMutation
|
|
from ...rest_framework.models import MyFakeModel
|
|
from ...rest_framework.mutation import SerializerMutation
|
|
|
|
|
|
class MyModelSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = MyFakeModel
|
|
fields = "__all__"
|
|
|
|
|
|
class MyForm(forms.Form):
|
|
text = forms.CharField()
|
|
|
|
|
|
def test_can_use_form_and_serializer_mutations():
|
|
class MyMutation(SerializerMutation):
|
|
class Meta:
|
|
serializer_class = MyModelSerializer
|
|
|
|
class MyFormMutation(DjangoFormMutation):
|
|
class Meta:
|
|
form_class = MyForm
|
|
|
|
class Mutation(graphene.ObjectType):
|
|
my_mutation = MyMutation.Field()
|
|
my_form_mutation = MyFormMutation.Field()
|
|
|
|
graphene.Schema(mutation=Mutation)
|