mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Fixed field type when parent object type is a inputtype
This commit is contained in:
parent
129999d41a
commit
bd30bbb322
|
@ -134,7 +134,7 @@ class Field(object):
|
|||
object_type = self.get_object_type(schema)
|
||||
if object_type and object_type._meta.is_mutation:
|
||||
assert not self.args, 'Arguments provided for mutations are defined in Input class in Mutation'
|
||||
args = object_type.input_type.fields_as_arguments(schema)
|
||||
args = object_type.get_input_type().fields_as_arguments(schema)
|
||||
|
||||
internal_type = self.internal_type(schema)
|
||||
if not internal_type:
|
||||
|
@ -151,11 +151,13 @@ class Field(object):
|
|||
else:
|
||||
resolver = self.resolve
|
||||
|
||||
field_type = GraphQLField
|
||||
if object_type and issubclass(object_type, InputObjectType):
|
||||
field_type = GraphQLInputObjectField
|
||||
if issubclass(self.object_type, InputObjectType):
|
||||
return GraphQLInputObjectField(
|
||||
internal_type,
|
||||
description=description,
|
||||
)
|
||||
|
||||
return field_type(
|
||||
return GraphQLField(
|
||||
internal_type,
|
||||
description=description,
|
||||
args=args,
|
||||
|
@ -164,7 +166,7 @@ class Field(object):
|
|||
|
||||
def __str__(self):
|
||||
""" Return "object_type.name". """
|
||||
return '%s.%s' % (self.object_type, self.field_name)
|
||||
return '%s.%s' % (self.object_type.__name__, self.field_name)
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
|
|
|
@ -23,7 +23,7 @@ class ObjectTypeMeta(type):
|
|||
return Interface in parents
|
||||
|
||||
def is_mutation(cls, parents):
|
||||
return Mutation in parents
|
||||
return issubclass(cls, Mutation)
|
||||
|
||||
def __new__(cls, name, bases, attrs):
|
||||
super_new = super(ObjectTypeMeta, cls).__new__
|
||||
|
@ -218,7 +218,9 @@ class ObjectType(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
|
|||
|
||||
|
||||
class Mutation(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
|
||||
pass
|
||||
@classmethod
|
||||
def get_input_type(cls):
|
||||
return getattr(cls, 'input_type', None)
|
||||
|
||||
|
||||
class InputObjectType(ObjectType):
|
||||
|
|
|
@ -31,10 +31,7 @@ class ObjectType(object):
|
|||
def __str__(self):
|
||||
return "ObjectType"
|
||||
|
||||
ot = ObjectType()
|
||||
|
||||
ObjectType._meta.contribute_to_class(ObjectType, '_meta')
|
||||
|
||||
ot = ObjectType
|
||||
|
||||
schema = Schema()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user