A schema of:
type Foo {
bar: String
}
union Bar = Foo
type Query {
bar: Bar
}
With:
models:
Baz:
fields:
foo:
resolver: true
Will generate a resolver with signature:
func (r *queryResolver) Bar(ctx context.Context) (Bar, error) {
panic("not implemented")
}
A resolver with signature:
func (r *queryResolver) Bar(ctx context.Context) (*Bar, error) {
panic("not implemented")
}
is generated where *Bar is a pointer to the Go interface Bar.
I've worked around this for now by making the type not nullable in the GraphQL schema:
type Query {
bar: Bar!
}
But this means the schema is not accurately expressing the fact that null can also be returned.
This seems similar to https://github.com/99designs/gqlgen/issues/484
schema.graphql
type Foo {
bar: String
}
union Bar = Foo
type Query {
bar: Bar
}
gengql.yml
# .gqlgen.yml example
#
# Refer to https://gqlgen.com/config/
# for detailed .gqlgen.yml documentation.
schema:
- schema.graphql
exec:
filename: generated.go
model:
filename: models_gen.go
resolver:
filename: resolver.go
type: Resolver
models:
Baz:
fields:
foo:
resolver: true
Notably, interface types seem to do the right thing here; just not union types.
This appears to be a regression as v0.7.1 generates the right code:
package test_gqlgen
import (
"context"
)
type Resolver struct{}
func (r *Resolver) Query() QueryResolver {
return &queryResolver{r}
}
type queryResolver struct{ *Resolver }
func (r *queryResolver) Bar(ctx context.Context) (Bar, error) {
panic("not implemented")
}
Any plans when the new version with this bug fix will be released?
0.8.2 is getting closer
Awesome, thank you for all of your hard work!