Skip to content

Commit

Permalink
Added interfaces field into a ObjectType. Fixed #168
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed May 19, 2016
1 parent c260bd4 commit 10304eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion graphene/contrib/django/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from graphql.type import GraphQLObjectType
from mock import patch

from graphene import Schema
from graphene import Schema, Interface
from graphene.contrib.django.types import DjangoNode, DjangoObjectType
from graphene.core.fields import Field
from graphene.core.types.scalars import Int
Expand Down Expand Up @@ -83,3 +83,20 @@ def test_object_type():
def test_node_notinterface():
assert Human._meta.interface is False
assert DjangoNode in Human._meta.interfaces


def test_django_objecttype_could_extend_interface():
schema = Schema()

@schema.register
class Customer(Interface):
id = Int()

@schema.register
class UserType(DjangoObjectType):
class Meta:
model = Reporter
interfaces = [Customer]

object_type = schema.T(UserType)
assert schema.T(Customer) in object_type.get_interfaces()
1 change: 1 addition & 0 deletions graphene/core/classtypes/objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ObjectTypeOptions(FieldsOptions):
def __init__(self, *args, **kwargs):
super(ObjectTypeOptions, self).__init__(*args, **kwargs)
self.interface = False
self.valid_attrs += ['interfaces']
self.interfaces = []


Expand Down

0 comments on commit 10304eb

Please sign in to comment.