Skip to content

Commit 10304eb

Browse files
committed
Added interfaces field into a ObjectType. Fixed #168
1 parent c260bd4 commit 10304eb

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

graphene/contrib/django/tests/test_types.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from graphql.type import GraphQLObjectType
22
from mock import patch
33

4-
from graphene import Schema
4+
from graphene import Schema, Interface
55
from graphene.contrib.django.types import DjangoNode, DjangoObjectType
66
from graphene.core.fields import Field
77
from graphene.core.types.scalars import Int
@@ -83,3 +83,20 @@ def test_object_type():
8383
def test_node_notinterface():
8484
assert Human._meta.interface is False
8585
assert DjangoNode in Human._meta.interfaces
86+
87+
88+
def test_django_objecttype_could_extend_interface():
89+
schema = Schema()
90+
91+
@schema.register
92+
class Customer(Interface):
93+
id = Int()
94+
95+
@schema.register
96+
class UserType(DjangoObjectType):
97+
class Meta:
98+
model = Reporter
99+
interfaces = [Customer]
100+
101+
object_type = schema.T(UserType)
102+
assert schema.T(Customer) in object_type.get_interfaces()

graphene/core/classtypes/objecttype.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ObjectTypeOptions(FieldsOptions):
2020
def __init__(self, *args, **kwargs):
2121
super(ObjectTypeOptions, self).__init__(*args, **kwargs)
2222
self.interface = False
23+
self.valid_attrs += ['interfaces']
2324
self.interfaces = []
2425

2526

0 commit comments

Comments
 (0)