You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
go version go1.21.8 darwin/arm64
The text was updated successfully, but these errors were encountered:
MikhailLipanin
changed the title
Federation plugin: combination of explicit_requires with entity multi-resolver works as not expected
proposal: Federation plugin: combination of explicit_requires with entity multi-resolver works as not expected
Jun 2, 2024
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 onfederation:options:explicit_requires: true
in yourgqlgen.yml
, it will generateFindMany...
entity resolver. But will not generatefederation.requires.go
file with resolving@requires
fields. However, it just fills all nested@requires
fields infederation.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
withPopulate...
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 bothimportantInfo
and fields in@requires
:versions
go run github.com/99designs/gqlgen version
?v0.17.45
go version
?go version go1.21.8 darwin/arm64
The text was updated successfully, but these errors were encountered: