def implementation_is_subtype_of_interface(): iface = GraphQLInterfaceType( 'Interface', {'field': GraphQLField(GraphQLString)}) impl = GraphQLObjectType( 'Object', fields={'field': GraphQLField(GraphQLString)}, interfaces=[iface]) schema = test_schema(impl) assert is_type_sub_type_of(schema, impl, iface)
def implementation_is_subtype_of_interface(): iface = GraphQLInterfaceType( "Interface", {"field": GraphQLField(GraphQLString)}) impl = GraphQLObjectType( "Object", fields={"field": GraphQLField(GraphQLString)}, interfaces=[iface], ) schema = _test_schema(impl) assert is_type_sub_type_of(schema, impl, iface)
def implementing_interface_is_subtype_of_interface(): iface = GraphQLInterfaceType( "Interface", {"field": GraphQLField(GraphQLString)}) iface2 = GraphQLInterfaceType( "Interface2", {"field": GraphQLField(GraphQLString)}, [iface]) impl = GraphQLObjectType( "Object", {"field": GraphQLField(GraphQLString)}, [iface2, iface], ) schema = _test_schema(impl) assert is_type_sub_type_of(schema, iface2, iface)
def member_is_subtype_of_union(): member = GraphQLObjectType("Object", {"field": GraphQLField(GraphQLString)}) union = GraphQLUnionType("Union", [member]) schema = _test_schema(union) assert is_type_sub_type_of(schema, member, union)
def list_is_not_subtype_of_item(): assert not is_type_sub_type_of(_test_schema(), GraphQLList(GraphQLInt), GraphQLInt)
def item_is_not_subtype_of_list(): assert not is_type_sub_type_of(_test_schema(), GraphQLInt, GraphQLList(GraphQLInt))
def nullable_is_not_subtype_of_non_null(): assert (is_type_sub_type_of(_test_schema(), GraphQLInt, GraphQLNonNull(GraphQLInt)) is False)
def non_null_is_subtype_of_nullable(): assert (is_type_sub_type_of(_test_schema(), GraphQLNonNull(GraphQLInt), GraphQLInt) is True)
def int_is_not_subtype_of_float(): assert (is_type_sub_type_of(_test_schema(), GraphQLInt, GraphQLFloat) is False)
def same_reference_is_subtype(): assert (is_type_sub_type_of(_test_schema(), GraphQLString, GraphQLString) is True)
def member_is_subtype_of_union(): member = GraphQLObjectType('Object', {'field': GraphQLField(GraphQLString)}) union = GraphQLUnionType('Union', [member]) schema = test_schema(union) assert is_type_sub_type_of(schema, member, union)