Home > Software engineering >  too many parameters returned by Resolver.ModuleName
too many parameters returned by Resolver.ModuleName

Time:01-20

I am working on breaking the monolithic architecture into Microservice architecture. I did that but when I am building the code in my current repository I am getting this error.

We use graphql-gophers library

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

Has anyone ever seen this error in golang using graphql for querying?

Tried so many things but nothing has worked.

Any help would be appreciated

CodePudding user response:

The error message comes from graph-gophers/graphql-go internal/exec/resolvable/resolvable.go#makeFieldExec

It is called when you parse a schema which does not match the field of an existing struct.

The one illustrated in example/customerrors/starwars.go does match every field and would not trigger the error message:

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
}

Its resolver does use the right parameters:

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"}
}

Try and use that example to check it does work, then modify it to transition to your own code.

  •  Tags:  
  • Related