99designs / 99designs/gqlgen

Is there a way to auto deside when to call a resolver with a ` @goField(forceResolver: true)`

未关闭
#3,446 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
10.8k
派生
1.3k
平均合并
2 天 36 分钟
30 天内合并 PR
26

描述

### What happened?

If I set a ` @goField(forceResolver: true)` directive, it will be called anyway

### What did you expect?

We need a mechanism to automatically determine whether to invoke a resolver, instead of manually parsing fields to determine whether to execute.

like this:

```graphql
type Product {
productId: ID!

name: String!

extraFields: Any
}

type Project implements Node {
id: ID!

name: String!

products: [Product!] @goField(forceResolver: true, forceResolverIgnoredKeys: ["productId", "name"])
}

type Query {
project(id: ID!) Project!
}
```

the query will not call the `products` resolver in `Project`

```graphql
query {
project(id: "xxxxx") {
id
name
products {
productId # or name or both of them
}
}
}
```

the query will call resolver

```graphql
query {
project(id: "xxxxx") {
id
name
products {
productId
name
extraFields
}
}
}
```

### Minimal graphql.schema and models to reproduce

None

### versions
- `go run github.com/99designs/gqlgen version`? `v0.17.61`
- `go version`? `go version go1.23.4 linux/amd64`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。