Set interface list to be immutable

This commit is contained in:
Syrus Akbary 2016-06-06 01:29:05 -07:00
parent 251d7106e2
commit 01130b8af5
2 changed files with 4 additions and 4 deletions

View File

@ -70,7 +70,7 @@ class ObjectTypeMeta(ClassTypeMeta):
name=cls._meta.name or cls.__name__,
description=cls._meta.description,
fields=FieldMap(cls, bases=filter(None, inherited_types)),
interfaces=list(cls.get_interfaces()),
interfaces=tuple(cls.get_interfaces()),
)
@ -81,7 +81,7 @@ def implements(*interfaces):
interface_types = get_interfaces(cls, interfaces)
graphql_type = cls._meta.graphql_type
new_type = copy.copy(graphql_type)
new_type._provided_interfaces.extend(interface_types)
new_type._provided_interfaces = tuple(graphql_type._provided_interfaces) + tuple(interface_types)
cls._meta.graphql_type = new_type
cls._meta.graphql_type.check_interfaces()
return cls

View File

@ -144,7 +144,7 @@ def test_objecttype_graphql_interface():
interfaces = [MyInterface]
graphql_type = GrapheneObjectType._meta.graphql_type
assert graphql_type.get_interfaces() == [MyInterface]
assert graphql_type.get_interfaces() == (MyInterface, )
# assert graphql_type.is_type_of(MyInterface, None, None)
fields = graphql_type.get_fields()
assert 'field' in fields
@ -159,7 +159,7 @@ def test_objecttype_graphene_interface():
interfaces = [GrapheneInterface]
graphql_type = GrapheneObjectType._meta.graphql_type
assert graphql_type.get_interfaces() == [GrapheneInterface._meta.graphql_type]
assert graphql_type.get_interfaces() == (GrapheneInterface._meta.graphql_type, )
assert graphql_type.is_type_of(GrapheneObjectType(), None, None)
fields = graphql_type.get_fields()
assert 'field' in fields