mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-23 01:56:54 +03:00
Make node arg options and default required to True for GlobalID.
This commit is contained in:
parent
50eadde8b2
commit
5f7af3e43f
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user