Bug with multi-resolver for federation and custom ID type
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
https://github.com/99designs/gqlgen/pull/3632 introduced a bug in generating our federated graph.
Our schema looks like this:
```graphqls
extend type Thing @key(fields: "id") @entityResolver(multi: true) {
id: ID!
}
```
The generated code in federation.go changed from:
```go
func (ec *executionContext) resolveManyEntities(
...
case "Thing":
...
case "findManyThingByIDs":
...
id0, err := ec.unmarshalNID2string(ctx, rep.entity["id"])
```
to
```
id0, err := ec.unmarshalNID2githubᚗcomᚋsomethingᚋscalarᚐID(ctx, rep.entity["id"])
```
We have a custom scalar ID model (I don't know why TBH, looks like something silly we did a long time ago and forgot about).
The ID type:
```go
type ID string
func (id ID) MarshalJSON() ([]byte, error) {
return strconv.AppendQuote(nil, string(id)), nil
}
func (id ID) MarshalGQL(w io.Writer) {
_, _ = w.Write(strconv.AppendQuote(nil, string(id)))
}
func (id *ID) UnmarshalGQL(v interface{}) error {
switch v := v.(type) {
case string:
*id = ID(v)
return nil
case int64:
*id = ID(strconv.FormatInt(v, 10))
return nil
default:
return stacktrace.NewError("%T is not an ID", v)
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.