My gqlgen
models:
models:
Int64:
model:
- github.com/99designs/gqlgen/graphql.Int64
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Int:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int32
- github.com/99designs/gqlgen/graphql.Int64
in schema.graphql:
type Value{
t: Int64!
}
I keep getting : failed to load schema: graph/schema.graphqls:97: Undefined type Int64.
and I'm unsure as to why. I tried adding a custom type myself and referencing that in models
func MarshalInt64(t int64) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatInt(t, 10))
})
}
func UnmarshalInt64(v interface{}) (int64, error) {
if res, ok := v.(json.Number); ok {
return res.Int64()
}
if res, ok := v.(string); ok {
return json.Number(res).Int64()
}
if res, ok := v.(int64); ok {
return res, nil
}
if res, ok := v.(*int64); ok {
return *res, nil
}
return 0, fmt.Errorf("could not convert %v of type %T to Int64", v, v)
}
But same problem happens. Any ideas?
I figured out what the issue was, seems like you need to add the custom type directly to your schema.
Adding scalar Int64
to my schema.graphqls
fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With