Ejemplo n.º 1
0
    def resolve_type(self, resolve_type_func, type_name, root, info, _type):
        type_ = resolve_type_func(root, info)

        if not type_:
            return_type = self[type_name]
            return default_type_resolver(root, info, return_type)

        if inspect.isclass(type_) and issubclass(type_, ObjectType):
            graphql_type = self.get(type_._meta.name)
            assert graphql_type, f"Can't find type {type_._meta.name} in schema"
            assert (
                graphql_type.graphene_type == type_
            ), f"The type {type_} does not match with the associated graphene type {graphql_type.graphene_type}."
            return graphql_type

        return type_
Ejemplo n.º 2
0
def resolve_type(resolve_type_func, map_, type_name, root, info, _type):
    type_ = resolve_type_func(root, info)

    if not type_:
        return_type = map_[type_name]
        return default_type_resolver(root, info, return_type)

    if inspect.isclass(type_) and issubclass(type_, ObjectType):
        graphql_type = map_.get(type_._meta.name)
        assert graphql_type, "Can't find type {} in schema".format(
            type_._meta.name)
        assert graphql_type.graphene_type == type_, (
            "The type {} does not match with the associated graphene type {}."
        ).format(type_, graphql_type.graphene_type)
        return graphql_type

    return type_