-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(compiler): add a failing test for #742
- Loading branch information
1 parent
f1debb1
commit 89493e6
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#[test] | ||
fn long_fragment_chains_do_not_overflow_stack() { | ||
// Build a query that applies thousands of fragments | ||
// Validating it would take a lot of recursion and blow the stack | ||
let mut query = r#" | ||
query Introspection{ | ||
__schema { | ||
types { | ||
...typeFragment1 | ||
} | ||
} | ||
} | ||
"# | ||
.to_string(); | ||
|
||
let fragments: usize = 10_000; | ||
for i in 1..fragments { | ||
query.push_str(&format!( | ||
" | ||
fragment typeFragment{i} on __Type {{ | ||
ofType {{ | ||
...typeFragment{} | ||
}} | ||
}}", | ||
i + 1 | ||
)); | ||
} | ||
query.push_str(&format!( | ||
" | ||
fragment typeFragment{fragments} on __Type {{ | ||
ofType {{ | ||
name | ||
}} | ||
}}" | ||
)); | ||
|
||
let (schema, executable) = apollo_compiler::parse_mixed( | ||
format!( | ||
"type Query {{ a: Int }} | ||
{query}" | ||
), | ||
"overflow.graphql", | ||
); | ||
executable.validate(&schema).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod fragments; | ||
mod interface; | ||
mod object; | ||
mod operation; | ||
|