Skip to content

Commit e9c9aa8

Browse files
committed
Add integration test reproducing panic when schema is outside project sources
This test reproduces a panic that occurs when using a multi-project config where the schema file is not located within any project's source directory. The panic occurs at build_schema.rs:115 with 'no entry found for key' because the schema is not loaded into compiler_state.schemas for projects when the schema path is outside the project's configured source directory. Reproduction: https://github.com/budde377/relay-multirepo-reproduction
1 parent 803e42d commit e9c9aa8

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@nocommit
2+
Run snapshot tests with UPDATE_SNAPSHOTS=1 to update this new file.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//- a/C.js
2+
graphql`
3+
fragment A_data on Query {
4+
hello
5+
}
6+
`
7+
8+
//- b/C.js
9+
graphql`
10+
fragment B_data on Query {
11+
hello
12+
}
13+
`
14+
15+
//- relay.config.json
16+
{
17+
"projects": {
18+
"a": {
19+
"schema": "./schema.graphql",
20+
"language": "typescript"
21+
},
22+
"b": {
23+
"schema": "./schema.graphql",
24+
"language": "typescript"
25+
}
26+
},
27+
"sources": {
28+
"a": "a",
29+
"b": "b"
30+
}
31+
}
32+
33+
//- schema.graphql
34+
type Query {
35+
hello: String
36+
}

compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<58e190b62dc6455639e5995e15b0447b>>
7+
* @generated SignedSource<<9b8f55dbad5a1ece9f3780b116bb8730>>
88
*/
99

1010
mod relay_compiler_integration;
@@ -446,6 +446,13 @@ async fn resolvers_with_context_path_import() {
446446
test_fixture(transform_fixture, file!(), "resolvers_with_context_path_import.input", "relay_compiler_integration/fixtures/resolvers_with_context_path_import.expected", input, expected).await;
447447
}
448448

449+
#[tokio::test]
450+
async fn schema_not_in_project_sources() {
451+
let input = include_str!("relay_compiler_integration/fixtures/schema_not_in_project_sources.input");
452+
let expected = include_str!("relay_compiler_integration/fixtures/schema_not_in_project_sources.expected");
453+
test_fixture(transform_fixture, file!(), "schema_not_in_project_sources.input", "relay_compiler_integration/fixtures/schema_not_in_project_sources.expected", input, expected).await;
454+
}
455+
449456
#[tokio::test]
450457
async fn semantic_null_require_bubble_to_required_parent() {
451458
let input = include_str!("relay_compiler_integration/fixtures/semantic_null_require_bubble_to_required_parent.input");

0 commit comments

Comments
 (0)