99designs / 99designs/gqlgen

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

Open
#3,446 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.8k
Forks
1.3k
Avg merge
2d 36m
Merged PRs (30d)
26

Description

### 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`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.