@@ -136,6 +136,16 @@ fn ast_to_prop_value(
136136 // print the types.
137137 let ( safe_key, original_key) = get_safe_key ( key) ;
138138
139+ let mut new_at_path = current_path. clone ( ) ;
140+ new_at_path. push ( key. to_string ( ) ) ;
141+
142+ // The catch result type in Relay is shaped as `{ok: true, value: 'value} | {ok: false, errors: array<catchErrors>}`.
143+ // This sets the path up here to follow into `value`, which is where the OK result will be located if it's an OK
144+ // response.
145+ if is_from_result {
146+ new_at_path. push ( String :: from ( "value" ) ) ;
147+ }
148+
139149 // We do special treatment for any variable definition in
140150 // mutations/subscriptions which is passed into `connections` of a
141151 // store updater directive (like @appendNode, @deleteEdge, etc).
@@ -264,13 +274,6 @@ fn ast_to_prop_value(
264274 }
265275 }
266276 AST :: ExactObject ( props) => {
267- let mut new_at_path = current_path. clone ( ) ;
268- new_at_path. push ( key. to_string ( ) ) ;
269-
270- if is_from_result {
271- new_at_path. push ( String :: from ( "value" ) ) ;
272- }
273-
274277 let record_name = path_to_name ( & new_at_path) ;
275278
276279 let object_props = get_object_props ( state, & new_at_path, props, found_in_union, context) ;
@@ -319,13 +322,6 @@ fn ast_to_prop_value(
319322 } )
320323 }
321324 AST :: Union ( members) => {
322- let mut new_at_path = current_path. clone ( ) ;
323- new_at_path. push ( key. to_string ( ) ) ;
324-
325- if is_from_result {
326- new_at_path. push ( String :: from ( "value" ) ) ;
327- }
328-
329325 let ( union_members, include_catch_all) = extract_union_members ( state, & new_at_path, members, context) ;
330326
331327 let union_record_name = path_to_name ( & new_at_path) ;
@@ -374,13 +370,6 @@ fn ast_to_prop_value(
374370 } )
375371 }
376372 ClassifiedIdentifier :: RawIdentifier ( identifier) => {
377- let mut new_at_path = current_path. clone ( ) ;
378- new_at_path. push ( key. to_string ( ) ) ;
379-
380- if is_from_result {
381- new_at_path. push ( String :: from ( "value" ) ) ;
382- }
383-
384373 let mut is_custom_scalar_that_needs_conversion = false ;
385374
386375 // Add a conversion instruction if this is a custom type
@@ -677,12 +666,17 @@ fn get_object_prop_type_as_string(
677666 field_path_name : & Vec < String > ,
678667) -> String {
679668 match & prop_value {
680- & PropType :: Result ( value ) => {
681- format ! ( "RescriptRelay.CatchResult.t<{}>" , get_object_prop_type_as_string( state,
682- value. as_ref( ) ,
683- & context,
684- indentation,
685- field_path_name) )
669+ & PropType :: Result ( value) => {
670+ format ! (
671+ "RescriptRelay.CatchResult.t<{}>" ,
672+ get_object_prop_type_as_string(
673+ state,
674+ value. as_ref( ) ,
675+ & context,
676+ indentation,
677+ field_path_name
678+ )
679+ )
686680 } ,
687681 & PropType :: DataId => String :: from ( "RescriptRelay.dataId" ) ,
688682 & PropType :: Enum ( enum_name) => {
@@ -1176,31 +1170,6 @@ fn write_converter_map(
11761170 )
11771171 . unwrap ( ) ;
11781172 }
1179- ConverterInstructions :: IsResult => {
1180- if !has_instructions {
1181- has_instructions = true ;
1182- writeln ! ( str , "{{" ) . unwrap ( ) ;
1183- }
1184-
1185- let fn_name = match direction {
1186- ConversionDirection :: Wrap => String :: from ( "internal_wrapResult" ) ,
1187- ConversionDirection :: Unwrap => String :: from ( "internal_unwrapResult" ) ,
1188- } ;
1189-
1190- if printed_instruction_keys. contains ( & fn_name) {
1191- return ;
1192- } else {
1193- printed_instruction_keys. push ( fn_name. clone ( ) ) ;
1194- }
1195-
1196- write_indentation ( str, indentation + 1 ) . unwrap ( ) ;
1197- writeln ! (
1198- str ,
1199- "\" wrapResult$\" : RescriptRelay_Internal.{}," ,
1200- fn_name
1201- )
1202- . unwrap ( ) ;
1203- }
12041173 _ => ( ) ,
12051174 } ;
12061175 } ) ;
@@ -1292,8 +1261,7 @@ fn write_internal_assets(
12921261 write_indentation ( str, indentation) . unwrap ( ) ;
12931262 writeln ! ( str , ")" ) . unwrap ( ) ;
12941263
1295- // Converters are either unions (that needs to be wrapped/unwrapped),
1296- // results (that also needs to be unwrapped), or
1264+ // Converters are either unions (that needs to be wrapped/unwrapped), or
12971265 // custom scalars _that are ReScript modules_, and therefore should be
12981266 // autoconverted.
12991267 let converters: Vec < & InstructionContainer > = target_conversion_instructions
@@ -1307,8 +1275,7 @@ fn write_internal_assets(
13071275 RescriptCustomTypeValue :: Module => true ,
13081276 }
13091277 }
1310- ConverterInstructions :: ConvertUnion ( _)
1311- | ConverterInstructions :: IsResult => true ,
1278+ ConverterInstructions :: ConvertUnion ( _) => true ,
13121279 _ => false ,
13131280 }
13141281 } )
0 commit comments