@@ -339,7 +339,8 @@ pub fn shopify_function_target(
339
339
output_result_type,
340
340
& target_handle_string. to_case( Case :: Camel )
341
341
) ;
342
- let output_struct = generate_output_struct ( & output_query, schema_path. as_str ( ) ) ;
342
+ let output_struct =
343
+ generate_output_struct ( & output_query, schema_path. as_str ( ) , extern_enums. as_deref ( ) ) ;
343
344
344
345
if let Err ( error) = extract_shopify_function_return_type ( & ast) {
345
346
return error. to_compile_error ( ) . into ( ) ;
@@ -417,7 +418,7 @@ pub fn generate_types(attr: proc_macro::TokenStream) -> proc_macro::TokenStream
417
418
) ;
418
419
let output_query =
419
420
"mutation Output($result: FunctionResult!) {\n handleResult(result: $result)\n }\n " ;
420
- let output_struct = generate_output_struct ( output_query, & schema_path) ;
421
+ let output_struct = generate_output_struct ( output_query, & schema_path, extern_enums . as_deref ( ) ) ;
421
422
422
423
quote ! {
423
424
#input_struct
@@ -451,18 +452,28 @@ fn generate_input_struct(
451
452
}
452
453
}
453
454
454
- fn graphql_codegen_options ( operation_name : String ) -> GraphQLClientCodegenOptions {
455
+ fn graphql_codegen_options (
456
+ operation_name : String ,
457
+ extern_enums : Option < & [ String ] > ,
458
+ ) -> GraphQLClientCodegenOptions {
455
459
let mut options = GraphQLClientCodegenOptions :: new ( CodegenMode :: Derive ) ;
456
460
options. set_operation_name ( operation_name) ;
457
461
options. set_response_derives ( "Clone,Debug,PartialEq,Deserialize,Serialize" . to_string ( ) ) ;
458
462
options. set_variables_derives ( "Clone,Debug,PartialEq,Deserialize" . to_string ( ) ) ;
459
463
options. set_skip_serializing_none ( true ) ;
464
+ if let Some ( extern_enums) = extern_enums {
465
+ options. set_extern_enums ( extern_enums. to_vec ( ) ) ;
466
+ }
460
467
461
468
options
462
469
}
463
470
464
- fn generate_output_struct ( query : & str , schema_path : & str ) -> proc_macro2:: TokenStream {
465
- let options = graphql_codegen_options ( "Output" . to_string ( ) ) ;
471
+ fn generate_output_struct (
472
+ query : & str ,
473
+ schema_path : & str ,
474
+ extern_enums : Option < & [ String ] > ,
475
+ ) -> proc_macro2:: TokenStream {
476
+ let options = graphql_codegen_options ( "Output" . to_string ( ) , extern_enums) ;
466
477
let cargo_manifest_dir =
467
478
std:: env:: var ( "CARGO_MANIFEST_DIR" ) . expect ( "Error reading CARGO_MANIFEST_DIR from env" ) ;
468
479
let schema_path = Path :: new ( & cargo_manifest_dir) . join ( schema_path) ;
0 commit comments