@@ -20,7 +20,7 @@ mod subscription_e2e_tests {
2020 }
2121
2222 #[ ntex:: test]
23- async fn subscription_no_entity_resolution_sse ( ) {
23+ async fn subscription_no_entity_resolution_sse_subgraph ( ) {
2424 let _subgraphs_server = SubgraphsServer :: start_with_subscriptions_protocol (
2525 subgraphs:: SubscriptionProtocol :: SseOnly ,
2626 )
@@ -107,7 +107,7 @@ mod subscription_e2e_tests {
107107 }
108108
109109 #[ ntex:: test]
110- async fn subscription_no_entity_resolution_multipart ( ) {
110+ async fn subscription_no_entity_resolution_multipart_subgraph ( ) {
111111 let _subgraphs_server = SubgraphsServer :: start_with_subscriptions_protocol (
112112 subgraphs:: SubscriptionProtocol :: MultipartOnly ,
113113 )
@@ -278,6 +278,106 @@ mod subscription_e2e_tests {
278278 ) ;
279279 }
280280
281+ #[ ntex:: test]
282+ async fn subscription_yes_entity_resolution_multipart_client ( ) {
283+ let _subgraphs_server = SubgraphsServer :: start ( ) . await ;
284+
285+ let router = init_router_from_config_inline ( & format ! (
286+ r#"
287+ supergraph:
288+ source: file
289+ path: supergraph.graphql
290+ "#
291+ ) )
292+ . await
293+ . unwrap ( ) ;
294+
295+ wait_for_readiness ( & router. app ) . await ;
296+
297+ let req = init_graphql_request (
298+ r#"
299+ subscription {
300+ reviewAdded(intervalInMs: 0) {
301+ id
302+ product {
303+ name
304+ }
305+ }
306+ }
307+ "# ,
308+ None ,
309+ )
310+ . header (
311+ http:: header:: ACCEPT ,
312+ // as per https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol#executing-a-subscription
313+ r#"multipart/mixed;subscriptionSpec="1.0", application/json"# ,
314+ )
315+ . to_request ( ) ;
316+
317+ let res = test:: call_service ( & router. app , req) . await ;
318+
319+ assert ! ( res. status( ) . is_success( ) , "Expected 200 OK" ) ;
320+
321+ let content_type_header = get_content_type_header ( & res) ;
322+
323+ let body = test:: read_body ( res) . await ;
324+ let body_str = std:: str:: from_utf8 ( & body) . unwrap ( ) ;
325+
326+ assert_snapshot ! ( body_str, @r#"
327+ --graphql
328+ Content-Type: application/json
329+
330+ {"payload":{"data":{"reviewAdded":{"id":"1","product":{"name":"Table"}}}}}
331+ --graphql
332+ Content-Type: application/json
333+
334+ {"payload":{"data":{"reviewAdded":{"id":"2","product":{"name":"Table"}}}}}
335+ --graphql
336+ Content-Type: application/json
337+
338+ {"payload":{"data":{"reviewAdded":{"id":"3","product":{"name":"Table"}}}}}
339+ --graphql
340+ Content-Type: application/json
341+
342+ {"payload":{"data":{"reviewAdded":{"id":"4","product":{"name":"Table"}}}}}
343+ --graphql
344+ Content-Type: application/json
345+
346+ {"payload":{"data":{"reviewAdded":{"id":"5","product":{"name":"Couch"}}}}}
347+ --graphql
348+ Content-Type: application/json
349+
350+ {"payload":{"data":{"reviewAdded":{"id":"6","product":{"name":"Couch"}}}}}
351+ --graphql
352+ Content-Type: application/json
353+
354+ {"payload":{"data":{"reviewAdded":{"id":"7","product":{"name":"Couch"}}}}}
355+ --graphql
356+ Content-Type: application/json
357+
358+ {"payload":{"data":{"reviewAdded":{"id":"8","product":{"name":"Couch"}}}}}
359+ --graphql
360+ Content-Type: application/json
361+
362+ {"payload":{"data":{"reviewAdded":{"id":"9","product":{"name":"Glass"}}}}}
363+ --graphql
364+ Content-Type: application/json
365+
366+ {"payload":{"data":{"reviewAdded":{"id":"10","product":{"name":"Chair"}}}}}
367+ --graphql
368+ Content-Type: application/json
369+
370+ {"payload":{"data":{"reviewAdded":{"id":"11","product":{"name":"Chair"}}}}}
371+ --graphql--
372+ "# ) ;
373+
374+ // we check this at the end because the body will hold clues to why the test fails
375+ assert_eq ! (
376+ content_type_header, "multipart/mixed;boundary=graphql" ,
377+ "Expected Content-Type to be multipart/mixed;boundary=graphql"
378+ ) ;
379+ }
380+
281381 #[ ntex:: test]
282382 async fn subscription_entity_resolution_with_requires ( ) {
283383 let _subgraphs_server = SubgraphsServer :: start ( ) . await ;
0 commit comments