Skip to content

Commit

Permalink
Fix codemod crashing on aliases in inline fragments
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D69204227

fbshipit-source-id: 4b7c7a5ddb66048fd0394585ff93a55c8b5ecd99
  • Loading branch information
gordyf authored and facebook-github-bot committed Feb 5, 2025
1 parent ac7a7c7 commit 002f9ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion compiler/crates/relay-codemod/src/codemod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ pub async fn run_codemod(
}
}
AvailableCodemod::RemoveUnnecessaryRequiredDirectives => {
disallow_required_on_non_null_field(&programs.source).unwrap_or_default()
match disallow_required_on_non_null_field(&programs.source) {
Ok(e) => e,
Err(e) => panic!("{:?}", e),
}
}
})
.collect::<Vec<_>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use lazy_static::lazy_static;
use schema::SDLSchema;
use schema::Schema;

use crate::fragment_alias_directive;
use crate::required_directive;
use crate::ValidationMessageWithData;
use crate::CATCH_DIRECTIVE_NAME;
Expand All @@ -51,7 +52,8 @@ pub fn disallow_required_on_non_null_field(
// required_directive transform. This validation is run on untransformed
// versions of IR both in the LSP and as a codemod, so we apply the transform
// ourselves locally.
let program = required_directive(program)?;
let program = fragment_alias_directive(program, &common::FeatureFlag::Disabled)?;
let program = required_directive(&program)?;
let mut validator = DisallowRequiredOnNonNullField::new(&program.schema);
validator.validate_program(&program)?;
Ok(validator.warnings)
Expand Down

0 comments on commit 002f9ed

Please sign in to comment.