How to use custom resolver implementation
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
I am trying to figure out how to use an existing resolver implementation. But when I run `go run github.com/99designs/gqlgen generate`, it overwrites the implementation in the `schema.resolvers.go` file.
I am using [this](https://github.com/nrfta/go-paging) package to add pagination to my GraphQL server.
I add the following to my `gqlgen.yaml` file:
```
models:
PageArgs:
model: github.com/nrfta/go-paging.PageArgs
PageInfo:
model: github.com/nrfta/go-paging.PageInfo
```
This is what is inside my `resolver.go`:
```
package graph
//go:generate go run github.com/99designs/gqlgen generate
import (
"github.com/nrfta/go-paging"
"github.com/gobuffalo/pop/v6"
)
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.
type Resolver struct {
db *pop.Connection
}
func (r *Resolver) PageInfo() paging.PageInfoResolver {
return paging.NewPageInfoResolver()
}
```
When I run `go run github.com/99designs/gqlgen generate`, I would expect my `schema.resolvers.go` to *not* contain the auto-generated `pageInfoResolver` struct `PageInfo()` method, since I have already provided an implementation. However, they get generated, and I get the following error:
```
validation failed: packages.Load: /home/wheeler/Repositories/.../graph/schema.resolvers.go:70:20: method Resolver.PageInfo already declared at /home/wheeler/Repositories/.../graph/resolver.go:18:20
exit status 1
graph/resolver.go:3: running "go": exit status 1
```
How do I get gqlgen to stop auto-generating the methods that return the sub-resolvers if the methods are already defined?
贡献指南
评估
这个 Issue 还没有评估数据。