Removed unused code. Small refactor

This commit is contained in:
Syrus Akbary 2016-08-13 23:15:20 -07:00
parent 3f3bb113ce
commit 99eec49a06
8 changed files with 21 additions and 55 deletions

View File

@ -102,25 +102,11 @@ class ConnectionMeta(ObjectTypeMeta):
class Connection(six.with_metaclass(ConnectionMeta, ObjectType)):
resolve_node = None
resolve_cursor = None
# def __init__(self, *args, **kwargs):
# super(Connection, self).__init__(*args, **kwargs)
# print args, kwargs
# print dir(self.page_info)
pass
class IterableConnectionField(Field):
def __init__(self, type, *args, **kwargs):
# arguments = kwargs.pop('args', {})
# if not arguments:
# arguments = connection_args
# else:
# arguments = copy.copy(arguments)
# arguments.update(connection_args)
super(IterableConnectionField, self).__init__(
type,
*args,

View File

@ -27,8 +27,7 @@ class GlobalID(Field):
@staticmethod
def id_resolver(parent_resolver, node, root, args, context, info):
id = parent_resolver(root, args, context, info)
# type_name = root._meta.name # info.parent_type.name
return node.to_global_id(info.parent_type.name, id)
return node.to_global_id(info.parent_type.name, id) # root._meta.name
def get_resolver(self, parent_resolver):
return partial(self.id_resolver, parent_resolver, self.node)
@ -39,11 +38,6 @@ class NodeMeta(InterfaceMeta):
def __new__(cls, name, bases, attrs):
cls = InterfaceMeta.__new__(cls, name, bases, attrs)
cls._meta.fields['id'] = GlobalID(cls, required=True, description='The ID of the object.')
# new_fields = OrderedDict([
# ('id', GlobalID(cls, required=True, description='The ID of the object.'))
# ])
# new_fields.update(cls._meta.fields)
# cls._meta.fields = new_fields
return cls

View File

@ -26,7 +26,7 @@ def to_arguments(args, extra_args):
arguments = OrderedDict()
for default_name, arg in iter_arguments:
if isinstance(arg, UnmountedType):
arg = arg.as_argument()
arg = arg.Argument()
if not isinstance(arg, Argument):
raise ValueError('Unknown argument "{}".'.format(default_name))

View File

@ -35,8 +35,7 @@ class InputObjectTypeMeta(AbstractTypeMeta):
class InputObjectType(six.with_metaclass(InputObjectTypeMeta, UnmountedType)):
@classmethod
def get_type(cls):
return cls
# def __init__(self, *args, **kwargs):
# raise Exception("An InputObjectType cannot be intitialized")

View File

@ -53,7 +53,7 @@ class ObjectType(six.with_metaclass(ObjectTypeMeta)):
is_type_of = None
def __init__(self, *args, **kwargs):
# GraphQL ObjectType acting as container
# ObjectType acting as container
args_len = len(args)
fields = self._meta.fields.items()
if args_len > len(fields):

View File

@ -42,15 +42,7 @@ class Schema(GraphQLSchema):
)
self._directives = directives
initial_types = [
query,
mutation,
subscription,
IntrospectionSchema
]
if types:
initial_types += types
self._type_map = TypeMap(initial_types)
self.build_typemap()
def get_query_type(self):
return self.get_graphql_type(self._query)
@ -97,18 +89,13 @@ class Schema(GraphQLSchema):
def lazy(self, _type):
return lambda: self.get_type(_type)
# def rebuild(self):
# self._possible_type_map = defaultdict(set)
# self._type_map = self._build_type_map(self.types)
# # Keep track of all implementations by interface name.
# self._implementations = defaultdict(list)
# for type in self._type_map.values():
# if isinstance(type, GraphQLObjectType):
# for interface in type.get_interfaces():
# self._implementations[interface.name].append(type)
# # Enforce correct interface implementations.
# for type in self._type_map.values():
# if isinstance(type, GraphQLObjectType):
# for interface in type.get_interfaces():
# assert_object_implements_interface(self, type, interface)
def build_typemap(self):
initial_types = [
self._query,
self._mutation,
self._subscription,
IntrospectionSchema
]
if self.types:
initial_types += self.types
self._type_map = TypeMap(initial_types)

View File

@ -23,7 +23,7 @@ class UnmountedType(OrderedType):
def get_type(self):
raise NotImplementedError("get_type not implemented in {}".format(self))
def as_field(self):
def Field(self):
'''
Mount the UnmountedType as Field
'''
@ -35,7 +35,7 @@ class UnmountedType(OrderedType):
**self.kwargs
)
def as_inputfield(self):
def InputField(self):
'''
Mount the UnmountedType as InputField
'''
@ -47,7 +47,7 @@ class UnmountedType(OrderedType):
**self.kwargs
)
def as_argument(self):
def Argument(self):
'''
Mount the UnmountedType as Argument
'''

View File

@ -33,12 +33,12 @@ def unmounted_field_in_type(attname, unmounted_field, type):
from ..types.inputobjecttype import InputObjectType
if issubclass(type, (ObjectType, Interface)):
return unmounted_field.as_field()
return unmounted_field.Field()
elif issubclass(type, (AbstractType)):
return unmounted_field
elif issubclass(type, (InputObjectType)):
return unmounted_field.as_inputfield()
return unmounted_field.InputField()
raise Exception(
'Unmounted field "{}" cannot be mounted in {}.{}.'.format(