What happened?
Suppose you have an entity type, and your subgraph adds field to it - some function, that @requires other @external field in this entity. If you turn on federation:options:explicit_requires: true in your gqlgen.yml, it will generate FindMany... entity resolver. But will not generate federation.requires.go file with resolving @requires fields. However, it just fills all nested @requires fields in federation.go generated code, so, it will cause panic, if some nested fields in @requires are optional/mutually exclusive.
What did you expect?
Generating federation.requires.go with Populate... method, that takes list of entities and reps map as an argument.
Minimal graphql.schema and models to reproduce
In this example, to process getHeroWithWeapon, we need both importantInfo and fields in @requires:
type Hero @key(fileds: "id") @entityResolver(multi:true){
id: ID!
weapon: Weapon @external
getHeroWithWeapon(
importantInfo: SomeHeroInfo!
): DangerousHero @requires(fields: "weapon { id slug }")
}
type Weapon @shareable{
// we can identify weapon by ID OR Slug:
id: ID
slug: String
}
versions
go run github.com/99designs/gqlgen version?
v0.17.45
go version go1.21.8 darwin/arm64