Hi there,
I'm trying to use interfaces to work around duplicate Go types being generated for the same GQL types when they're used in different queries. Something like this:
// genqlient code
package gql
type Query_Foo struct {
Bar *string
Baz *GetFoo_Foo_Baz
}
type GetFoo_Foo_Baz struct {
Quux *int
}
func (v *Query_Foo) GetBar() *string {
return v.Bar
}
func (v *Query_Foo) GetBaz() *Query_Foo_Baz {
return v.Baz
}
func (v *GetFoo_Foo_Baz) GetQuux() *int {
return v.Quux
}
// My code
package example
type gqlFoo interface {
GetBar() *string
}
var a *gql.Query_Foo
x := func(gqlFoo) {}
x(a)
This works fine for accessing non-struct types, but when I try to do the same for Query_Foo.Baz, it breaks:
type gqlFoo interface {
GetBar() *string
GetBaz() *gqlBaz
}
type gqlBaz interface {
GetQuux() *int
}
var a *gql.Query_Foo
x := func(gqlFoo) {}
x(a)
redacted/foo.go: cannot use a (variable of type *gql.Query_Foo) as example.gqlFoo value in argument to x:
*gql.Query_Foo does not implement gqlFoo (wrong type for method GetBaz)
have GetBaz() *Query_Foo_Baz
want GetBaz() *gqlBaz
I feel like I'm missing something obvious... can I work around this?
Thanks in advance!
Hi there,
I'm trying to use interfaces to work around duplicate Go types being generated for the same GQL types when they're used in different queries. Something like this:
This works fine for accessing non-struct types, but when I try to do the same for
Query_Foo.Baz, it breaks:I feel like I'm missing something obvious... can I work around this?
Thanks in advance!