Skip to content

Commit 8f93027

Browse files
captbaritonefacebook-github-bot
authored andcommitted
Improve test fixture output for errors in throwOnFieldError transforms
Reviewed By: evanyeung Differential Revision: D65447769 fbshipit-source-id: b0f5a8014c4d1ae7d7635b4fcab9f78eb463132e
1 parent 8421851 commit 8f93027

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use fixture_tests::Fixture;
1414
use graphql_ir::build;
1515
use graphql_ir::ExecutableDefinition;
1616
use graphql_syntax::parse_executable;
17+
use graphql_test_helpers::diagnostics_to_sorted_string;
1718
use relay_codegen::print_fragment;
1819
use relay_codegen::print_operation;
1920
use relay_config::ProjectConfig;
@@ -69,11 +70,5 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String>
6970
.collect::<Vec<_>>()
7071
.join("\n\n")
7172
})
72-
.map_err(|errors| {
73-
errors
74-
.into_iter()
75-
.map(|error| format!("{:?}", error))
76-
.collect::<Vec<_>>()
77-
.join("\n\n")
78-
})
73+
.map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))
7974
}

compiler/crates/relay-codegen/tests/throw_on_field_error_directive_codegen/fixtures/throw_on_field_error_mutation_directive.expected

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ mutation MyMutation @throwOnFieldError {
77
}
88
}
99
==================================== ERROR ====================================
10-
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: {} })
10+
✖︎ Directive 'throwOnFieldError' not supported in this location. Supported location(s): QUERY, FRAGMENT_DEFINITION
11+
12+
throw_on_field_error_mutation_directive.graphql:3:22
13+
2 │
14+
3 │ mutation MyMutation @throwOnFieldError {
15+
│ ^^^^^^^^^^^^^^^^^
16+
4 │ setName(name: "Alice") {

0 commit comments

Comments
 (0)