99designs / 99designs/gqlgen

usage of field resolver when it is used in multiple resolvers

Đang mở
#1,448 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
10.8k
Fork
1.3k
Merge trung bình
2 ngày 36 phút
Pull request đã merge (30 ngày)
26

Mô tả

### What happened?
Followed this link https://github.com/99designs/gqlgen#using-explicit-resolvers to have field based resolvers so that they are fetched only when they are asked for.
```
Todo:
fields:
user:
resolver: true
```
Below is the model, and the two queries which returns this model.
```
type Todo {
id(version1: String!): ID! @directive1
text: String!
done: Boolean! @deprecated(reason: "some reason")
user: User!
}

type Query {
todos(version: String!): [Todo!]!
todos_ex(version: String!): [Todo!]!
}
```
On performing `go run github.com/99designs/gqlgen generate`, below is the resolver got added.
```
func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) {
```

But, I have a requirement to perform different operations in `User` `todoResolver` based on the type of query resolver which it is called.
Same model `Todo` might be returned in mutations as well.

It would be helpful if there are steps that I can do to achieve this.
### What did you expect?

I expected a seperate field resolver for each query/mutation/subscription resolver it is returned from (or) any other way to achieve this.

### Minimal graphql.schema and models to reproduce

### versions
- `gqlgen version`?
- `go version`?
go1.14.2
- dep or go modules?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.