mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-22 22:09:57 +03:00
Merge bc8f56b33a
into 6853142232
This commit is contained in:
commit
8bf8db44fb
|
@ -5,6 +5,8 @@ import six
|
|||
|
||||
|
||||
class InstanceType(object):
|
||||
def _get_true_type(self, _type):
|
||||
return _type() if ('function' in str(type(_type))) else _type
|
||||
|
||||
def internal_type(self, schema):
|
||||
raise NotImplementedError("internal_type for type {} is not implemented".format(self.__class__.__name__))
|
||||
|
|
|
@ -12,13 +12,16 @@ class OfType(MountedType):
|
|||
self.of_type = of_type
|
||||
super(OfType, self).__init__(*args, **kwargs)
|
||||
|
||||
def get_type(self):
|
||||
return self._get_true_type(self.of_type)
|
||||
|
||||
def internal_type(self, schema):
|
||||
return self.T(schema.T(self.of_type))
|
||||
return self.T(schema.T(self.get_type()))
|
||||
|
||||
def mount(self, cls):
|
||||
self.parent = cls
|
||||
if isinstance(self.of_type, MountType):
|
||||
self.of_type.mount(cls)
|
||||
self.get_type().mount(cls)
|
||||
|
||||
|
||||
class List(OfType):
|
||||
|
|
|
@ -84,9 +84,10 @@ class Field(NamedType, OrderedType):
|
|||
return default_getter
|
||||
|
||||
def get_type(self, schema):
|
||||
_type = self._get_true_type(self.type)
|
||||
if self.required:
|
||||
return NonNull(self.type)
|
||||
return self.type
|
||||
return NonNull(_type)
|
||||
return _type
|
||||
|
||||
def decorate_resolver(self, resolver):
|
||||
return snake_case_args(resolver)
|
||||
|
|
Loading…
Reference in New Issue
Block a user