Skip to content

Commit

Permalink
Allow types to be abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Jul 27, 2017
1 parent e71b59a commit c7c6112
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 1 addition & 3 deletions graphene/types/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class Interface(BaseType):
when the field is resolved.
'''
@classmethod
def __init_subclass_with_meta__(cls, abstract=False, _meta=None, **options):
if abstract:
return
def __init_subclass_with_meta__(cls, _meta=None, **options):
if not _meta:
_meta = InterfaceOptions(cls)

Expand Down
4 changes: 1 addition & 3 deletions graphene/types/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class Mutation(ObjectType):
'''
@classmethod
def __init_subclass_with_meta__(cls, resolver=None, output=None, arguments=None,
_meta=None, abstract=False, **options):
if abstract:
return
_meta=None, **options):
if not _meta:
_meta = MutationOptions(cls)

Expand Down
4 changes: 1 addition & 3 deletions graphene/types/objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class ObjectType(BaseType):
def __init_subclass_with_meta__(
cls, interfaces=(),
possible_types=(),
default_resolver=None, _meta=None, abstract=False, **options):
if abstract:
return
default_resolver=None, _meta=None, **options):
if not _meta:
_meta = ObjectTypeOptions(cls)

Expand Down
14 changes: 11 additions & 3 deletions graphene/utils/subclass_with_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ def __init_subclass__(cls, **meta_options):
raise Exception("Meta have to be either a class or a dict. Received {}".format(_Meta))
delattr(cls, "Meta")
options = dict(meta_options, **_meta_props)
super_class = super(cls, cls)
if hasattr(super_class, '__init_subclass_with_meta__'):
super_class.__init_subclass_with_meta__(**options)

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)
if hasattr(super_class, '__init_subclass_with_meta__'):
super_class.__init_subclass_with_meta__(**options)

@classmethod
def __init_subclass_with_meta__(cls, **meta_options):
Expand Down

0 comments on commit c7c6112

Please sign in to comment.