Replies: 6 comments
-
Hi, I'm new to gqlgen, but I'm also getting this symptom. It occurred for me immediately after adding a custom scalar type:
I am able to recreate this issue with the following schema: schema {
query: TestQuery
}
type TestQuery {
test: ByteArray
}
scalar ByteArray We appear to be triggering the issue in this part of the template: Line 49 in 997da42 |
Beta Was this translation helpful? Give feedback.
-
I'm stumbling in the dark a little here, I'm not used to this codebase, but from some digging: The root of the issue seems like it's to do with how the When you have
This means that in Line 49 in 997da42 Unfortunately, in the case of named type definitions, the gqlgen/codegen/config/binder.go Lines 177 to 204 in 997da42 Judging by the Not sure what the best course of action is :) |
Beta Was this translation helpful? Give feedback.
-
For reference, you can work around this issue for now by wrapping the byte slice (in this example) in a struct: type ByteArray struct {
Value []byte
}
// UnmarshalGQL implements the graphql.Unmarshaler interface
func (b *ByteArray) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("ByteArray must be a string")
}
arr, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return fmt.Errorf("ByteArray must be valid base64: %w", err)
}
b.Value = arr
return nil
}
// MarshalGQL implements the graphql.Marshaler interface
func (b ByteArray) MarshalGQL(w io.Writer) {
jsonStr := fmt.Sprintf(`"%s"`, base64.StdEncoding.EncodeToString(b.Value))
_, _ = w.Write([]byte(jsonStr))
} It's not ideal but only a minor inconvenience :) |
Beta Was this translation helpful? Give feedback.
-
same problem |
Beta Was this translation helpful? Give feedback.
-
I too am having the same issue with a custom type that is a slice of string. |
Beta Was this translation helpful? Give feedback.
-
I seem to be having this issue with models I'm choosing to define as maps as documented here: https://gqlgen.com/reference/changesets/ |
Beta Was this translation helpful? Give feedback.
-
What happened?
I was using v0.11.3 and gqlgen works fine.
Updating to v0.13.0, and now gqlgen crashes.
What did you expect?
I expected v0.13.0 to still handle my schema.graphql, or at least to generate a meaningful error message.
Minimal graphql.schema and models to reproduce
$ go generate
generating core failed: type.gotpl: template: type.gotpl:49:28: executing "type.gotpl" at <$type.Elem.GO>: nil pointer evaluating *config.TypeReference.GOexit status 1
resolver.go:1: running "go": exit status 1
$
Haven't yet managed to distill it down to a small gqlgen case.
versions
gqlgen version
?v0.13.0
go version
?go 1.14.2
dep or go modules?
go modules
Beta Was this translation helpful? Give feedback.
All reactions