@@ -2471,6 +2471,49 @@ func TestQuery_NestedJoinedErrors(t *testing.T) {
24712471 }
24722472}
24732473
2474+ func TestQuery_MultipleErrorsFromResolverNonNull (t * testing.T ) {
2475+ queryType := graphql .NewObject (graphql.ObjectConfig {
2476+ Name : "Query" ,
2477+ Fields : graphql.Fields {
2478+ "value" : & graphql.Field {
2479+ Type : graphql .NewNonNull (graphql .Int ), // NonNull at top level
2480+ Resolve : func (p graphql.ResolveParams ) (interface {}, error ) {
2481+ return nil , errors .Join (
2482+ errors .New ("first error" ),
2483+ errors .New ("second error" ),
2484+ )
2485+ },
2486+ },
2487+ },
2488+ })
2489+
2490+ schema , err := graphql .NewSchema (graphql.SchemaConfig {
2491+ Query : queryType ,
2492+ })
2493+ if err != nil {
2494+ t .Fatalf ("failed to create schema: %v" , err )
2495+ }
2496+
2497+ result := graphql .Do (graphql.Params {
2498+ Schema : schema ,
2499+ RequestString : `{ value }` ,
2500+ })
2501+
2502+ if len (result .Errors ) != 2 {
2503+ t .Fatalf ("expected 2 errors, got %d: %+v" , len (result .Errors ), result .Errors )
2504+ }
2505+
2506+ expectedMessages := []string {
2507+ "first error" ,
2508+ "second error" ,
2509+ }
2510+ for i , err := range result .Errors {
2511+ if err .Message != expectedMessages [i ] {
2512+ t .Errorf ("error[%d]: expected message %q, got %q" , i , expectedMessages [i ], err .Message )
2513+ }
2514+ }
2515+ }
2516+
24742517type pathError struct {
24752518 msg string
24762519 path []interface {}
0 commit comments