mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-23 01:56:54 +03:00
Renamed from TypeProxy to UnmountedType
This commit is contained in:
parent
c0460060a0
commit
eec4c52c33
|
@ -41,13 +41,13 @@ class Argument(GraphQLArgument, OrderedType):
|
|||
|
||||
|
||||
def to_arguments(*args, **extra):
|
||||
from .proxy import TypeProxy
|
||||
from .unmountedtype import UnmountedType
|
||||
args = list(filter(None, args)) + [extra]
|
||||
arguments = []
|
||||
iter_arguments = chain(*[arg.items() for arg in args])
|
||||
arguments_names = set()
|
||||
for default_name, arg in iter_arguments:
|
||||
if isinstance(arg, TypeProxy):
|
||||
if isinstance(arg, UnmountedType):
|
||||
arg = arg.as_argument()
|
||||
|
||||
if not isinstance(arg, GraphQLArgument):
|
||||
|
|
|
@ -27,12 +27,6 @@ class ClassTypeMeta(type):
|
|||
meta = attr_meta
|
||||
|
||||
new_class._meta = new_class.get_options(meta)
|
||||
new_class._meta.parent = new_class
|
||||
new_class._meta.validate_attrs()
|
||||
|
||||
if new_class._meta.name:
|
||||
assert_valid_name(new_class._meta.name)
|
||||
|
||||
return mcs.construct(new_class, bases, attrs)
|
||||
|
||||
def get_options(cls, meta):
|
||||
|
|
|
@ -7,7 +7,7 @@ try:
|
|||
except ImportError:
|
||||
from ..utils.enum import Enum as PyEnum
|
||||
|
||||
from .proxy import TypeProxy
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType):
|
||||
|
@ -66,6 +66,6 @@ class EnumTypeMeta(ClassTypeMeta):
|
|||
return type(Meta.enum.__name__, (Enum,), {'Meta': Meta})
|
||||
|
||||
|
||||
class Enum(six.with_metaclass(EnumTypeMeta, TypeProxy)):
|
||||
class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -3,7 +3,7 @@ import six
|
|||
from graphql import GraphQLInputObjectType
|
||||
|
||||
from .definitions import FieldsMeta, ClassTypeMeta, GrapheneGraphQLType
|
||||
from .proxy import TypeProxy
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class GrapheneInputObjectType(GrapheneGraphQLType, GraphQLInputObjectType):
|
||||
|
@ -36,6 +36,6 @@ class InputObjectTypeMeta(FieldsMeta, ClassTypeMeta):
|
|||
return super(InputObjectTypeMeta, cls).construct(bases, attrs)
|
||||
|
||||
|
||||
class InputObjectType(six.with_metaclass(InputObjectTypeMeta, TypeProxy)):
|
||||
class InputObjectType(six.with_metaclass(InputObjectTypeMeta, UnmountedType)):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -2,7 +2,7 @@ import six
|
|||
from graphql import GraphQLScalarType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID
|
||||
|
||||
from .definitions import ClassTypeMeta, GrapheneGraphQLType
|
||||
from .proxy import TypeProxy
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class GrapheneScalarType(GrapheneGraphQLType, GraphQLScalarType):
|
||||
|
@ -36,7 +36,7 @@ class ScalarTypeMeta(ClassTypeMeta):
|
|||
return constructed
|
||||
|
||||
|
||||
class Scalar(six.with_metaclass(ScalarTypeMeta, TypeProxy)):
|
||||
class Scalar(six.with_metaclass(ScalarTypeMeta, UnmountedType)):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ import inspect
|
|||
|
||||
from graphql import GraphQLList, GraphQLNonNull
|
||||
|
||||
from .proxy import TypeProxy
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class Structure(TypeProxy):
|
||||
class Structure(UnmountedType):
|
||||
def __init__(self, of_type, *args, **kwargs):
|
||||
super(Structure, self).__init__(*args, **kwargs)
|
||||
self.of_type = of_type
|
||||
|
|
|
@ -5,7 +5,7 @@ from ..utils.orderedtype import OrderedType
|
|||
|
||||
# UnmountedType ?
|
||||
|
||||
class TypeProxy(OrderedType):
|
||||
class UnmountedType(OrderedType):
|
||||
'''
|
||||
This class acts a proxy for a Graphene Type, so it can be mounted
|
||||
as Field, InputField or Argument.
|
||||
|
@ -24,7 +24,7 @@ class TypeProxy(OrderedType):
|
|||
def __init__(self, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
super(TypeProxy, self).__init__()
|
||||
super(UnmountedType, self).__init__()
|
||||
|
||||
def get_type(self):
|
||||
return self._meta.graphql_type
|
|
@ -2,7 +2,7 @@ import copy
|
|||
from .get_graphql_type import get_graphql_type
|
||||
|
||||
from ..types.field import Field, InputField
|
||||
from ..types.proxy import TypeProxy
|
||||
from ..types.unmountedtype import UnmountedType
|
||||
|
||||
|
||||
def extract_fields(cls, attrs):
|
||||
|
@ -10,7 +10,7 @@ def extract_fields(cls, attrs):
|
|||
_fields = list()
|
||||
for attname, value in list(attrs.items()):
|
||||
is_field = isinstance(value, (Field, InputField))
|
||||
is_field_proxy = isinstance(value, TypeProxy)
|
||||
is_field_proxy = isinstance(value, UnmountedType)
|
||||
if not (is_field or is_field_proxy):
|
||||
continue
|
||||
field = value.as_mounted(cls) if is_field_proxy else copy.copy(value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user