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)): class Connection(six.with_metaclass(ConnectionMeta, ObjectType)):
resolve_node = None pass
resolve_cursor = None
# def __init__(self, *args, **kwargs):
# super(Connection, self).__init__(*args, **kwargs)
# print args, kwargs
# print dir(self.page_info)
class IterableConnectionField(Field): class IterableConnectionField(Field):
def __init__(self, type, *args, **kwargs): 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__( super(IterableConnectionField, self).__init__(
type, type,
*args, *args,

View File

@ -27,8 +27,7 @@ class GlobalID(Field):
@staticmethod @staticmethod
def id_resolver(parent_resolver, node, root, args, context, info): def id_resolver(parent_resolver, node, root, args, context, info):
id = parent_resolver(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) # root._meta.name
return node.to_global_id(info.parent_type.name, id)
def get_resolver(self, parent_resolver): def get_resolver(self, parent_resolver):
return partial(self.id_resolver, parent_resolver, self.node) return partial(self.id_resolver, parent_resolver, self.node)
@ -39,11 +38,6 @@ class NodeMeta(InterfaceMeta):
def __new__(cls, name, bases, attrs): def __new__(cls, name, bases, attrs):
cls = InterfaceMeta.__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.') 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 return cls

View File

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

View File

@ -35,8 +35,7 @@ class InputObjectTypeMeta(AbstractTypeMeta):
class InputObjectType(six.with_metaclass(InputObjectTypeMeta, UnmountedType)): class InputObjectType(six.with_metaclass(InputObjectTypeMeta, UnmountedType)):
@classmethod @classmethod
def get_type(cls): def get_type(cls):
return 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 is_type_of = None
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
# GraphQL ObjectType acting as container # ObjectType acting as container
args_len = len(args) args_len = len(args)
fields = self._meta.fields.items() fields = self._meta.fields.items()
if args_len > len(fields): if args_len > len(fields):

View File

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

View File

@ -23,7 +23,7 @@ class UnmountedType(OrderedType):
def get_type(self): def get_type(self):
raise NotImplementedError("get_type not implemented in {}".format(self)) raise NotImplementedError("get_type not implemented in {}".format(self))
def as_field(self): def Field(self):
''' '''
Mount the UnmountedType as Field Mount the UnmountedType as Field
''' '''
@ -35,7 +35,7 @@ class UnmountedType(OrderedType):
**self.kwargs **self.kwargs
) )
def as_inputfield(self): def InputField(self):
''' '''
Mount the UnmountedType as InputField Mount the UnmountedType as InputField
''' '''
@ -47,7 +47,7 @@ class UnmountedType(OrderedType):
**self.kwargs **self.kwargs
) )
def as_argument(self): def Argument(self):
''' '''
Mount the UnmountedType as Argument 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 from ..types.inputobjecttype import InputObjectType
if issubclass(type, (ObjectType, Interface)): if issubclass(type, (ObjectType, Interface)):
return unmounted_field.as_field() return unmounted_field.Field()
elif issubclass(type, (AbstractType)): elif issubclass(type, (AbstractType)):
return unmounted_field return unmounted_field
elif issubclass(type, (InputObjectType)): elif issubclass(type, (InputObjectType)):
return unmounted_field.as_inputfield() return unmounted_field.InputField()
raise Exception( raise Exception(
'Unmounted field "{}" cannot be mounted in {}.{}.'.format( 'Unmounted field "{}" cannot be mounted in {}.{}.'.format(