mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-25 19:13:57 +03:00
Allow InputObjectType instances to be Type proxies
This commit is contained in:
parent
50c1ab62ba
commit
0f10ae884f
|
@ -11,7 +11,7 @@ class Address(graphene.ObjectType):
|
|||
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
address = graphene.Field(Address, geo=graphene.Argument(GeoInput))
|
||||
address = graphene.Field(Address, geo=GeoInput())
|
||||
|
||||
def resolve_address(self, args, context, info):
|
||||
geo = args.get('geo')
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from .objecttype import ObjectType, implements
|
||||
from .inputobjecttype import InputObjectType
|
||||
from .interface import Interface
|
||||
from .scalars import Scalar, String, ID, Int, Float, Boolean
|
||||
from .schema import Schema
|
||||
|
@ -7,5 +6,6 @@ from .structures import List, NonNull
|
|||
from .enum import Enum
|
||||
from .field import Field, InputField
|
||||
from .argument import Argument
|
||||
from .inputobjecttype import InputObjectType
|
||||
|
||||
__all__ = ['ObjectType', 'InputObjectType', 'Interface', 'implements', 'Enum', 'Field', 'InputField', 'Schema', 'Scalar', 'String', 'ID', 'Int', 'Float', 'Boolean', 'List', 'NonNull', 'Argument']
|
||||
|
|
|
@ -3,9 +3,6 @@ import inspect
|
|||
from graphql.type import GraphQLField, GraphQLInputObjectField
|
||||
from graphql.utils.assert_valid_name import assert_valid_name
|
||||
|
||||
from .objecttype import ObjectType
|
||||
from .inputobjecttype import InputObjectType
|
||||
from .interface import Interface
|
||||
from ..utils.orderedtype import OrderedType
|
||||
from ..utils.str_converters import to_camel_case
|
||||
from .argument import to_arguments
|
||||
|
@ -66,6 +63,9 @@ class Field(AbstractField, GraphQLField, OrderedType):
|
|||
)
|
||||
|
||||
def contribute_to_class(self, cls, attname):
|
||||
from .objecttype import ObjectType
|
||||
from .interface import Interface
|
||||
|
||||
assert issubclass(cls, (ObjectType, Interface)), self.mount_error_message(cls)
|
||||
self.attname = attname
|
||||
self.parent = cls
|
||||
|
@ -131,6 +131,8 @@ class InputField(AbstractField, GraphQLInputObjectField, OrderedType):
|
|||
)
|
||||
|
||||
def contribute_to_class(self, cls, attname):
|
||||
from .inputobjecttype import InputObjectType
|
||||
|
||||
assert issubclass(cls, (InputObjectType)), self.mount_error_message(cls)
|
||||
self.attname = attname
|
||||
self.parent = cls
|
||||
|
|
|
@ -3,6 +3,7 @@ import six
|
|||
from graphql import GraphQLInputObjectType
|
||||
|
||||
from .definitions import ClassTypeMeta, GrapheneFieldsType, FieldMap
|
||||
from .proxy import TypeProxy
|
||||
|
||||
|
||||
class GrapheneInputObjectType(GrapheneFieldsType, GraphQLInputObjectType):
|
||||
|
@ -38,6 +39,6 @@ class InputObjectTypeMeta(ClassTypeMeta):
|
|||
)
|
||||
|
||||
|
||||
class InputObjectType(six.with_metaclass(InputObjectTypeMeta)):
|
||||
class InputObjectType(six.with_metaclass(InputObjectTypeMeta, TypeProxy)):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
from .field import Field, InputField
|
||||
from .argument import Argument
|
||||
|
||||
|
||||
from .objecttype import ObjectType
|
||||
from .interface import Interface
|
||||
from .inputobjecttype import InputObjectType
|
||||
|
||||
from ..utils.orderedtype import OrderedType
|
||||
|
||||
|
||||
|
@ -43,6 +37,10 @@ class TypeProxy(OrderedType):
|
|||
)
|
||||
|
||||
def contribute_to_class(self, cls, attname):
|
||||
from .inputobjecttype import InputObjectType
|
||||
from .objecttype import ObjectType
|
||||
from .interface import Interface
|
||||
|
||||
if issubclass(cls, (ObjectType, Interface)):
|
||||
inner = self.as_field()
|
||||
elif issubclass(cls, (InputObjectType)):
|
||||
|
|
Loading…
Reference in New Issue
Block a user