mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-13 10:00:39 +03:00
Added interfaces field into a ObjectType. Fixed #168
This commit is contained in:
parent
c260bd4181
commit
10304eb8cf
|
@ -1,7 +1,7 @@
|
||||||
from graphql.type import GraphQLObjectType
|
from graphql.type import GraphQLObjectType
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from graphene import Schema
|
from graphene import Schema, Interface
|
||||||
from graphene.contrib.django.types import DjangoNode, DjangoObjectType
|
from graphene.contrib.django.types import DjangoNode, DjangoObjectType
|
||||||
from graphene.core.fields import Field
|
from graphene.core.fields import Field
|
||||||
from graphene.core.types.scalars import Int
|
from graphene.core.types.scalars import Int
|
||||||
|
@ -83,3 +83,20 @@ def test_object_type():
|
||||||
def test_node_notinterface():
|
def test_node_notinterface():
|
||||||
assert Human._meta.interface is False
|
assert Human._meta.interface is False
|
||||||
assert DjangoNode in Human._meta.interfaces
|
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()
|
||||||
|
|
|
@ -20,6 +20,7 @@ class ObjectTypeOptions(FieldsOptions):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ObjectTypeOptions, self).__init__(*args, **kwargs)
|
super(ObjectTypeOptions, self).__init__(*args, **kwargs)
|
||||||
self.interface = False
|
self.interface = False
|
||||||
|
self.valid_attrs += ['interfaces']
|
||||||
self.interfaces = []
|
self.interfaces = []
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user