Skip to content

Commit 3bf9aab

Browse files
committed
graphql: Verify that root fragments are expanded
Fixes #2720
1 parent d31fe03 commit 3bf9aab

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

graphql/tests/query.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,30 @@ fn can_query_many_to_many_relationship() {
574574
})
575575
}
576576

577+
#[test]
578+
fn root_fragments_are_expanded() {
579+
run_test_sequentially(|store| async move {
580+
let deployment = setup(store.as_ref());
581+
let query = graphql_parser::parse_query(
582+
r#"
583+
fragment Musicians on Query {
584+
musicians(first: 100, where: { name: "Tom" }) {
585+
name
586+
}
587+
}
588+
query MyQuery {
589+
...Musicians
590+
}"#,
591+
)
592+
.expect("invalid test query")
593+
.into_static();
594+
595+
let result = execute_query_document_with_variables(&deployment.hash, query, None).await;
596+
let exp = object! { musicians: vec![ object! { name: "Tom" }]};
597+
assert_eq!(extract_data!(result), Some(exp));
598+
})
599+
}
600+
577601
#[test]
578602
fn query_variables_are_used() {
579603
run_test_sequentially(|store| async move {

0 commit comments

Comments
 (0)