Make node arg options and default required to True for GlobalID.

This commit is contained in:
markus 2016-11-10 10:00:59 +00:00
parent 50eadde8b2
commit 5f7af3e43f

View File

@ -35,9 +35,9 @@ def get_default_connection(cls):
class GlobalID(Field): class GlobalID(Field):
def __init__(self, node, *args, **kwargs): def __init__(self, node=None, required=True, *args, **kwargs):
super(GlobalID, self).__init__(ID, *args, **kwargs) super(GlobalID, self).__init__(ID, required=required, *args, **kwargs)
self.node = node self.node = node or Node
@staticmethod @staticmethod
def id_resolver(parent_resolver, node, root, args, context, info): def id_resolver(parent_resolver, node, root, args, context, info):
@ -52,7 +52,7 @@ 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, description='The ID of the object.')
return cls return cls