Skip to content

Fix duplicated ErrorType declaration #539

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

Merged
merged 2 commits into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphene_django/forms/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from graphene_django.registry import get_global_registry

from .converter import convert_form_field
from .types import ErrorType
from ..types import ErrorType


def fields_for_form(form, only_fields, exclude_fields):
Expand Down
2 changes: 1 addition & 1 deletion graphene_django/rest_framework/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from graphene.types.objecttype import yank_fields_from_attrs

from .serializer_converter import convert_serializer_field
from .types import ErrorType
from ..types import ErrorType


class SerializerMutationOptions(MutationOptions):
Expand Down
5 changes: 0 additions & 5 deletions graphene_django/rest_framework/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
from graphene.types.unmountedtype import UnmountedType


class ErrorType(graphene.ObjectType):
field = graphene.String(required=True)
messages = graphene.List(graphene.NonNull(graphene.String), required=True)


class DictType(UnmountedType):
key = graphene.String()
value = graphene.String()
Empty file.
44 changes: 44 additions & 0 deletions graphene_django/tests/issues/test_520.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# https://github.com/graphql-python/graphene-django/issues/520

import datetime

from django import forms

import graphene

from graphene import Field, ResolveInfo
from graphene.types.inputobjecttype import InputObjectType
from py.test import raises
from py.test import mark
from rest_framework import serializers

from ...types import DjangoObjectType
from ...rest_framework.models import MyFakeModel
from ...rest_framework.mutation import SerializerMutation
from ...forms.mutation import DjangoFormMutation


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)
6 changes: 6 additions & 0 deletions graphene_django/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import OrderedDict

from django.utils.functional import SimpleLazyObject
import graphene
from graphene import Field
from graphene.relay import Connection, Node
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
Expand Down Expand Up @@ -133,3 +134,8 @@ def get_node(cls, info, id):
return cls._meta.model.objects.get(pk=id)
except cls._meta.model.DoesNotExist:
return None


class ErrorType(ObjectType):
field = graphene.String(required=True)
messages = graphene.List(graphene.NonNull(graphene.String), required=True)