@@ -3,6 +3,7 @@ package integration
3
3
import (
4
4
"cmp"
5
5
"encoding/json"
6
+ "github.com/wundergraph/cosmo/router/core"
6
7
"net/http"
7
8
"slices"
8
9
"testing"
@@ -1102,4 +1103,67 @@ func TestErrorPropagation(t *testing.T) {
1102
1103
require .Equal (t , `{"errors":[{"message":"Unauthorized","locations":[{"line":1,"column":1}],"extensions":{"code":"UNAUTHORIZED"}}],"data":{"employees":null}}` , res .Body )
1103
1104
})
1104
1105
})
1106
+
1107
+ t .Run ("validate error when a non subscription multipart is printed" , func (t * testing.T ) {
1108
+ t .Parallel ()
1109
+
1110
+ testenv .Run (t , & testenv.Config {
1111
+ NoRetryClient : true ,
1112
+ RouterOptions : []core.Option {
1113
+ core .WithEngineExecutionConfig (config.EngineExecutionConfiguration {
1114
+ EnableNetPoll : true ,
1115
+ EnableSingleFlight : true ,
1116
+ MaxConcurrentResolvers : 1 ,
1117
+ }),
1118
+ core .WithSubgraphRetryOptions (false , 0 , 0 , 0 ),
1119
+ },
1120
+ }, func (t * testing.T , xEnv * testenv.Environment ) {
1121
+ resp , err := xEnv .MakeGraphQLRequest (testenv.GraphQLRequest {
1122
+ Header : map [string ][]string {
1123
+ "service-name" : {"service-name" },
1124
+ "accept" : {"multipart/mixed;deferSpec=20220824" },
1125
+ },
1126
+ Query : `query employees { employees { ide } }` , // Missing closing bracket
1127
+ })
1128
+
1129
+ expected := "--graphql\r \n " +
1130
+ "Content-Type: application/json\r \n " +
1131
+ "\r \n " +
1132
+ "{\" errors\" :[{\" message\" :\" field: ide not defined on type: Employee\" ,\" path\" :[\" query\" ,\" employees\" ]}]}\r \n " +
1133
+ "--graphql--"
1134
+ require .Equal (t , expected , resp .Body )
1135
+ require .NoError (t , err )
1136
+ })
1137
+ })
1138
+
1139
+ t .Run ("validate the error format when a subscription multipart is printed" , func (t * testing.T ) {
1140
+ t .Parallel ()
1141
+
1142
+ testenv .Run (t , & testenv.Config {
1143
+ NoRetryClient : true ,
1144
+ RouterOptions : []core.Option {
1145
+ core .WithEngineExecutionConfig (config.EngineExecutionConfiguration {
1146
+ EnableNetPoll : true ,
1147
+ EnableSingleFlight : true ,
1148
+ MaxConcurrentResolvers : 1 ,
1149
+ }),
1150
+ core .WithSubgraphRetryOptions (false , 0 , 0 , 0 ),
1151
+ },
1152
+ }, func (t * testing.T , xEnv * testenv.Environment ) {
1153
+ resp , err := xEnv .MakeGraphQLRequest (testenv.GraphQLRequest {
1154
+ Header : map [string ][]string {
1155
+ "service-name" : {"service-name" },
1156
+ "accept" : {"multipart/mixed;deferSpec=20220824" },
1157
+ },
1158
+ Query : `subscription employees { employees { ide } }` , // Missing closing bracket
1159
+ })
1160
+
1161
+ expected := "--graphql\r \n " +
1162
+ "Content-Type: application/json\r \n " +
1163
+ "\r \n " +
1164
+ "{\" payload\" :{\" errors\" :[{\" message\" :\" field: employees not defined on type: Subscription\" ,\" path\" :[\" subscription\" ]}]}}"
1165
+ require .Equal (t , expected , resp .Body )
1166
+ require .NoError (t , err )
1167
+ })
1168
+ })
1105
1169
}
0 commit comments