99designs / 99designs/gqlgen

UInt fields now always require to write a getter resolver

Aperta
#2,550 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
10.8k
Fork
1.3k
Merge medio
2g 36m
PR unite (30g)
26

Descrizione

The behavior is a regression between 0.17.22 and 0.17.24.

On 0.17.24, everytime an object contain an UInt, that field requires to write a resolver getter (even though I have a custom marshaller) or it triggers the following error:

`UInt is incompatible with uint` or `ID is incompatible with uint`

On 0.17.22, it was able to figure it out.

The scalar are pointing to the following custom marshaller I have for UInt:
```go
// MarshalUInt returns a writer function for this object
func MarshalUInt(u uint) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, fmt.Sprint(u))
})
}

// UnmarshalUInt parses a graphQL object
func UnmarshalUInt(v interface{}) (uint, error) {

var tmp int64
var err error

switch v := v.(type) {
case json.Number:
tmp, err = v.Int64()
case int64:
tmp = v
default:
}
if err != nil {
return 0, serror.NewBadRequestError("UInt not a valid number")
}
if tmp < 0 {
return 0, serror.NewBadRequestError("UInt not a positive integer")
}
return uint(tmp), nil

}
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.