Renamed from TypeProxy to UnmountedType

This commit is contained in:
Syrus Akbary 2016-06-10 22:40:22 -07:00
parent c0460060a0
commit eec4c52c33
8 changed files with 14 additions and 20 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)