@@ -42,7 +42,7 @@ impl<'e> Executor<'e> {
4242 self . resp . into_inner ( )
4343 }
4444 RootNode :: Subscribe ( _) => Response {
45- data : ConstValue :: Null ,
45+ data : None ,
4646 errors : vec ! [ ServerError {
4747 message: "Not supported" . to_string( ) ,
4848 path: Default :: default ( ) ,
@@ -100,7 +100,7 @@ impl<'e> Executor<'e> {
100100 id,
101101 node. service ,
102102 RequestData :: new ( node. query . to_string ( ) )
103- . variables ( node. variables . to_variables ( ) ) ,
103+ . variables ( node. variables . to_variables ( ) ) ,
104104 tx. clone ( ) ,
105105 )
106106 . with_context ( cx) )
@@ -113,7 +113,7 @@ impl<'e> Executor<'e> {
113113 vec ! [ KEY_ERROR . string( err. to_string( ) ) ] ,
114114 ) ;
115115 Response {
116- data : ConstValue :: Null ,
116+ data : None ,
117117 errors : vec ! [ ServerError {
118118 message: err. to_string( ) ,
119119 path: Default :: default ( ) ,
@@ -193,7 +193,12 @@ impl<'e> Executor<'e> {
193193 async fn execute_introspection_node ( & self , introspection : & IntrospectionNode ) {
194194 let value = IntrospectionRoot . resolve ( & introspection. selection_set , self . schema ) ;
195195 let mut current_resp = self . resp . lock ( ) . await ;
196- merge_data ( & mut current_resp. data , value) ;
196+ if current_resp. data . is_none ( ) {
197+ current_resp. data = Some ( ConstValue :: Null )
198+ }
199+ if let Some ( data) = & mut current_resp. data {
200+ merge_data ( data, value) ;
201+ }
197202 }
198203
199204 async fn execute_fetch_node ( & self , fetcher : & impl Fetcher , fetch : & FetchNode < ' _ > ) {
@@ -231,7 +236,12 @@ impl<'e> Executor<'e> {
231236 if resp. errors . is_empty ( ) {
232237 add_tracing_spans ( & mut resp) ;
233238 current_resp. headers = resp. headers ;
234- merge_data ( & mut current_resp. data , resp. data ) ;
239+ if current_resp. data . is_none ( ) {
240+ current_resp. data = Some ( ConstValue :: Null )
241+ }
242+ if let Some ( data) = & mut current_resp. data {
243+ merge_data ( data, resp. data . unwrap_or ( ConstValue :: Null ) ) ;
244+ }
235245 } else {
236246 rewrite_errors ( None , & mut current_resp. errors , resp. errors ) ;
237247 }
@@ -407,7 +417,7 @@ impl<'e> Executor<'e> {
407417 let mut resp = self . resp . lock ( ) . await ;
408418 get_representations (
409419 & mut representations,
410- & mut resp. data ,
420+ resp. data . as_mut ( ) . unwrap_or ( & mut ConstValue :: Null ) ,
411421 & flatten. path ,
412422 flatten. prefix ,
413423 ) ;
@@ -467,10 +477,10 @@ impl<'e> Executor<'e> {
467477 Ok ( mut resp) => {
468478 if resp. errors . is_empty ( ) {
469479 add_tracing_spans ( & mut resp) ;
470- if let ConstValue :: Object ( mut data) = resp. data {
480+ if let ConstValue :: Object ( mut data) = resp. data . unwrap_or_default ( ) {
471481 if let Some ( ConstValue :: List ( values) ) = data. remove ( "_entities" ) {
472482 flatten_values (
473- & mut current_resp. data ,
483+ current_resp. data . as_mut ( ) . unwrap_or ( & mut ConstValue :: Null ) ,
474484 & flatten. path ,
475485 & mut values. into_iter ( ) . fuse ( ) ,
476486 & mut flags. into_iter ( ) . fuse ( ) ,
0 commit comments