From 8f93027349c7403018c0382acda6c876fa8aa706 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 5 Nov 2024 11:21:20 -0800 Subject: [PATCH] Improve test fixture output for errors in throwOnFieldError transforms Reviewed By: evanyeung Differential Revision: D65447769 fbshipit-source-id: b0f5a8014c4d1ae7d7635b4fcab9f78eb463132e --- .../tests/throw_on_field_error_directive_codegen.rs | 9 ++------- .../throw_on_field_error_mutation_directive.expected | 8 +++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen.rs b/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen.rs index 66c1235629630..3a0f39f3173ff 100644 --- a/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen.rs +++ b/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen.rs @@ -14,6 +14,7 @@ use fixture_tests::Fixture; use graphql_ir::build; use graphql_ir::ExecutableDefinition; use graphql_syntax::parse_executable; +use graphql_test_helpers::diagnostics_to_sorted_string; use relay_codegen::print_fragment; use relay_codegen::print_operation; use relay_config::ProjectConfig; @@ -69,11 +70,5 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result .collect::>() .join("\n\n") }) - .map_err(|errors| { - errors - .into_iter() - .map(|error| format!("{:?}", error)) - .collect::>() - .join("\n\n") - }) + .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics)) } diff --git a/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen/fixtures/throw_on_field_error_mutation_directive.expected b/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen/fixtures/throw_on_field_error_mutation_directive.expected index 713fd4e8611e3..3eece603f7ee6 100644 --- a/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen/fixtures/throw_on_field_error_mutation_directive.expected +++ b/compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen/fixtures/throw_on_field_error_mutation_directive.expected @@ -7,4 +7,10 @@ mutation MyMutation @throwOnFieldError { } } ==================================== ERROR ==================================== -Diagnostic(DiagnosticData { message: InvalidDirectiveUsageUnsupportedLocation { directive_name: DirectiveName("throwOnFieldError"), valid_locations: "QUERY, FRAGMENT_DEFINITION" }, location: throw_on_field_error_mutation_directive.graphql:42:59, related_information: [], tags: [], severity: Error, data: [], machine_readable: {} }) +✖︎ Directive 'throwOnFieldError' not supported in this location. Supported location(s): QUERY, FRAGMENT_DEFINITION + + throw_on_field_error_mutation_directive.graphql:3:22 + 2 │ + 3 │ mutation MyMutation @throwOnFieldError { + │ ^^^^^^^^^^^^^^^^^ + 4 │ setName(name: "Alice") {