mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-14 05:36:45 +03:00
Allow types to be abstract
This commit is contained in:
parent
e71b59a8c3
commit
c7c611266b
|
@ -19,9 +19,7 @@ class Interface(BaseType):
|
||||||
when the field is resolved.
|
when the field is resolved.
|
||||||
'''
|
'''
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init_subclass_with_meta__(cls, abstract=False, _meta=None, **options):
|
def __init_subclass_with_meta__(cls, _meta=None, **options):
|
||||||
if abstract:
|
|
||||||
return
|
|
||||||
if not _meta:
|
if not _meta:
|
||||||
_meta = InterfaceOptions(cls)
|
_meta = InterfaceOptions(cls)
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,7 @@ class Mutation(ObjectType):
|
||||||
'''
|
'''
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init_subclass_with_meta__(cls, resolver=None, output=None, arguments=None,
|
def __init_subclass_with_meta__(cls, resolver=None, output=None, arguments=None,
|
||||||
_meta=None, abstract=False, **options):
|
_meta=None, **options):
|
||||||
if abstract:
|
|
||||||
return
|
|
||||||
if not _meta:
|
if not _meta:
|
||||||
_meta = MutationOptions(cls)
|
_meta = MutationOptions(cls)
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,7 @@ class ObjectType(BaseType):
|
||||||
def __init_subclass_with_meta__(
|
def __init_subclass_with_meta__(
|
||||||
cls, interfaces=(),
|
cls, interfaces=(),
|
||||||
possible_types=(),
|
possible_types=(),
|
||||||
default_resolver=None, _meta=None, abstract=False, **options):
|
default_resolver=None, _meta=None, **options):
|
||||||
if abstract:
|
|
||||||
return
|
|
||||||
if not _meta:
|
if not _meta:
|
||||||
_meta = ObjectTypeOptions(cls)
|
_meta = ObjectTypeOptions(cls)
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,14 @@ class SubclassWithMeta(six.with_metaclass(SubclassWithMeta_Meta)):
|
||||||
raise Exception("Meta have to be either a class or a dict. Received {}".format(_Meta))
|
raise Exception("Meta have to be either a class or a dict. Received {}".format(_Meta))
|
||||||
delattr(cls, "Meta")
|
delattr(cls, "Meta")
|
||||||
options = dict(meta_options, **_meta_props)
|
options = dict(meta_options, **_meta_props)
|
||||||
|
|
||||||
|
abstract = options.pop('abstract', False)
|
||||||
|
if abstract:
|
||||||
|
assert not options, (
|
||||||
|
"Abstract types can only contain the abstract attribute. "
|
||||||
|
"Received: abstract, {option_keys}"
|
||||||
|
).format(option_keys=', '.join(options.keys()))
|
||||||
|
else:
|
||||||
super_class = super(cls, cls)
|
super_class = super(cls, cls)
|
||||||
if hasattr(super_class, '__init_subclass_with_meta__'):
|
if hasattr(super_class, '__init_subclass_with_meta__'):
|
||||||
super_class.__init_subclass_with_meta__(**options)
|
super_class.__init_subclass_with_meta__(**options)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user