gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

BUG: Panic when trying to return a struct that implements the desired interface

Open droslean opened this issue 3 years ago • 0 comments

What happened?

func (r *queryResolver) QueryMyInterface(ctx context.Context, filter *model.MyInterfaceFilter, order *model.MyInterfaceOrder, first *int, offset *int) ([]model.MyInterface, error) {

  var ifaces []model.MyInterface
  
  ifaces = append(ifaces, Test{.....})
 // Test implements the `model.MyInterface`
......
.....
  
 return ifaces --> That panics with error `unexpected type Test` when we call the `QueryMyInterface` operation

What did you expect?

I expect no errors.

Minimal graphql.schema and models to reproduce

versions

  • go run github.com/99designs/gqlgen version? v0.17.16
  • go version? go version go1.18.1 linux/amd64

/cc @vektah @neelance

Am I doing something wrong here?

droslean avatar Sep 09 '22 11:09 droslean