def print_type(type_: GraphQLNamedType) -> str: if is_scalar_type(type_): type_ = cast(GraphQLScalarType, type_) return print_scalar(type_) if is_object_type(type_): type_ = cast(GraphQLObjectType, type_) return print_object(type_) if is_interface_type(type_): type_ = cast(GraphQLInterfaceType, type_) return print_interface(type_) if is_union_type(type_): type_ = cast(GraphQLUnionType, type_) return print_union(type_) if is_enum_type(type_): type_ = cast(GraphQLEnumType, type_) return print_enum(type_) if is_input_object_type(type_): type_ = cast(GraphQLInputObjectType, type_) return print_input_object(type_) # Not reachable. All possible types have been considered. raise TypeError(f"Unexpected type: '{inspect(type_)}'.") # pragma: no cover
def returns_false_for_non_union_type(): assert is_union_type(ObjectType) is False with raises(TypeError): assert_union_type(ObjectType)
def returns_false_for_wrapped_union_type(): assert is_union_type(GraphQLList(UnionType)) is False with raises(TypeError): assert_union_type(GraphQLList(UnionType))
def returns_true_for_union_type(): assert is_union_type(UnionType) is True assert_union_type(UnionType)