猿问

Resolver.ModuleName 返回的参数太多

我正在努力将单体架构分解为微服务架构。我这样做了,但是当我在当前存储库中构建代码时,我收到了这个错误。

我们使用 graphql-gophers 库

panic: too many parameters returned by (Resolver).Dummy

有没有人在使用 graphql 进行查询的 golang 中看到过这个错误?

尝试了很多东西,但没有任何效果。

任何帮助,将不胜感激


POPMUISE
浏览 93回答 1
1回答

一只名叫tom的猫

错误信息来自graph-gophers/graphql-go internal/exec/resolvable/resolvable.go#makeFieldExec当您解析与现有结构的字段不匹配的模式时调用它。中所示的example/customerrors/starwars.go确实匹配每个字段并且不会触发错误消息:var Schema = `    schema {        query: Query    }    type Query {        droid(id: ID!): Droid!    }    # An autonomous mechanical character in the Star Wars universe    type Droid {        # The ID of the droid        id: ID!        # What others call this droid        name: String!    }`type droid struct {    ID   graphql.ID    Name string}它的解析器确实使用了正确的参数:type Resolver struct{}func (r *Resolver) Droid(args struct{ ID graphql.ID }) (*droidResolver, error) {    if d := droidData[args.ID]; d != nil {        return &droidResolver{d: d}, nil    }    return nil, &droidNotFoundError{Code: "NotFound", Message: "This is not the droid you are looking for"}}尝试使用该示例来检查它是否有效,然后对其进行修改以转换为您自己的代码。
随时随地看视频慕课网APP

相关分类

Go
我要回答