github.com/luciferinlove/gqlgen@v0.17.16-bzc.1/codegen/testserver/followschema/typefallback_test.go (about) 1 package followschema 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/luciferinlove/gqlgen/client" 8 "github.com/luciferinlove/gqlgen/graphql/handler" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestTypeFallback(t *testing.T) { 13 resolvers := &Stub{} 14 15 c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) 16 17 resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { 18 return arg, nil 19 } 20 21 t.Run("fallback to string passthrough", func(t *testing.T) { 22 var resp struct { 23 Fallback string 24 } 25 c.MustPost(`query { fallback(arg: A) }`, &resp) 26 require.Equal(t, "A", resp.Fallback) 27 }) 28 }