mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Set interface list to be immutable
This commit is contained in:
parent
251d7106e2
commit
01130b8af5
|
@ -70,7 +70,7 @@ class ObjectTypeMeta(ClassTypeMeta):
|
||||||
name=cls._meta.name or cls.__name__,
|
name=cls._meta.name or cls.__name__,
|
||||||
description=cls._meta.description,
|
description=cls._meta.description,
|
||||||
fields=FieldMap(cls, bases=filter(None, inherited_types)),
|
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)
|
interface_types = get_interfaces(cls, interfaces)
|
||||||
graphql_type = cls._meta.graphql_type
|
graphql_type = cls._meta.graphql_type
|
||||||
new_type = copy.copy(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 = new_type
|
||||||
cls._meta.graphql_type.check_interfaces()
|
cls._meta.graphql_type.check_interfaces()
|
||||||
return cls
|
return cls
|
||||||
|
|
|
@ -144,7 +144,7 @@ def test_objecttype_graphql_interface():
|
||||||
interfaces = [MyInterface]
|
interfaces = [MyInterface]
|
||||||
|
|
||||||
graphql_type = GrapheneObjectType._meta.graphql_type
|
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)
|
# assert graphql_type.is_type_of(MyInterface, None, None)
|
||||||
fields = graphql_type.get_fields()
|
fields = graphql_type.get_fields()
|
||||||
assert 'field' in fields
|
assert 'field' in fields
|
||||||
|
@ -159,7 +159,7 @@ def test_objecttype_graphene_interface():
|
||||||
interfaces = [GrapheneInterface]
|
interfaces = [GrapheneInterface]
|
||||||
|
|
||||||
graphql_type = GrapheneObjectType._meta.graphql_type
|
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)
|
assert graphql_type.is_type_of(GrapheneObjectType(), None, None)
|
||||||
fields = graphql_type.get_fields()
|
fields = graphql_type.get_fields()
|
||||||
assert 'field' in fields
|
assert 'field' in fields
|
||||||
|
|
Loading…
Reference in New Issue
Block a user