mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-23 10:03:54 +03:00
Fixed mutation input inheritance
This commit is contained in:
parent
8e5555a044
commit
135a171fe4
|
@ -4,7 +4,7 @@ from functools import partial
|
||||||
import six
|
import six
|
||||||
from promise import Promise
|
from promise import Promise
|
||||||
|
|
||||||
from ..types import Argument, Field, InputObjectType, String
|
from ..types import Argument, Field, InputObjectType, String, AbstractType
|
||||||
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from ..utils.props import props
|
from ..utils.props import props
|
||||||
|
@ -27,9 +27,14 @@ class ClientIDMutationMeta(ObjectTypeMeta):
|
||||||
"{}.mutate_and_get_payload method is required"
|
"{}.mutate_and_get_payload method is required"
|
||||||
" in a ClientIDMutation."
|
" in a ClientIDMutation."
|
||||||
).format(name)
|
).format(name)
|
||||||
input_attrs = props(input_class) if input_class else {}
|
input_attrs = {}
|
||||||
|
bases = ()
|
||||||
|
if not issubclass(input_class, AbstractType):
|
||||||
|
input_attrs = props(input_class) if input_class else {}
|
||||||
|
else:
|
||||||
|
bases += (input_class, )
|
||||||
input_attrs['client_mutation_id'] = String(name='clientMutationId')
|
input_attrs['client_mutation_id'] = String(name='clientMutationId')
|
||||||
cls.Input = type('{}Input'.format(base_name), (InputObjectType,), input_attrs)
|
cls.Input = type('{}Input'.format(base_name), bases + (InputObjectType,), input_attrs)
|
||||||
cls.Field = partial(Field, cls, resolver=cls.mutate, input=Argument(cls.Input))
|
cls.Field = partial(Field, cls, resolver=cls.mutate, input=Argument(cls.Input))
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ...types import (Argument, Field, InputField, InputObjectType, ObjectType,
|
from ...types import (Argument, Field, InputField, InputObjectType, ObjectType,
|
||||||
Schema)
|
Schema, AbstractType)
|
||||||
from ...types.scalars import String
|
from ...types.scalars import String
|
||||||
from ..mutation import ClientIDMutation
|
from ..mutation import ClientIDMutation
|
||||||
|
|
||||||
|
|
||||||
class SharedFields(object):
|
class SharedFields(AbstractType):
|
||||||
shared = String()
|
shared = String()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,6 @@ from ..node import Node
|
||||||
|
|
||||||
class SharedNodeFields(AbstractType):
|
class SharedNodeFields(AbstractType):
|
||||||
|
|
||||||
class Meta:
|
|
||||||
interfaces = (Node, )
|
|
||||||
|
|
||||||
shared = String()
|
shared = String()
|
||||||
something_else = String()
|
something_else = String()
|
||||||
|
|
||||||
|
@ -34,6 +31,9 @@ class MyNode(ObjectType):
|
||||||
class MyOtherNode(SharedNodeFields, ObjectType):
|
class MyOtherNode(SharedNodeFields, ObjectType):
|
||||||
extra_field = String()
|
extra_field = String()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
interfaces = (Node, )
|
||||||
|
|
||||||
def resolve_extra_field(self, *_):
|
def resolve_extra_field(self, *_):
|
||||||
return 'extra field info.'
|
return 'extra field info.'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user