Repository: apollographql/apollo-rs
Pull request #244 (2022-06-09 15:34:17)

resource bound parsing execution (followup)
This properly unifies the limits around recursion for both:
 - selection sets
 - fields

The tests are expanded and properly exercise the various possible outcomes with recursion limits.

Co-authored-by: Irina Shestak <shestak.irina@gmail.com>


Patch:
diff --git a/crates/apollo-parser/src/parser/grammar/field.rs b/crates/apollo-parser/src/parser/grammar/field.rs
index 4d5047c..27b3f65 100644
--- a/crates/apollo-parser/src/parser/grammar/field.rs
+++ b/crates/apollo-parser/src/parser/grammar/field.rs
@@ -9,14 +9,14 @@ use crate::{
 ///
 /// *Field*:
 ///     Alias? Name Arguments? Directives? SelectionSet?
-pub(crate) fn field(p: &mut Parser) -> bool {
+pub(crate) fn field(p: &mut Parser) {
     // We need to enforce recursion limits to prevent
     // excessive resource consumption or (more seriously)
     // stack overflows.
     p.recursion_limit.consume();
     if p.recursion_limit.limited() {
         p.limit_err(format!("parser limit({}) reached", p.recursion_limit.limit));
-        return true;
+        return;
     }
 
     let guard = p.start_node(SyntaxKind::FIELD);
@@ -46,7 +46,7 @@ pub(crate) fn field(p: &mut Parser) -> bool {
         Some(TokenKind::Name) => {
             guard.finish_node();
 
-            return field(p);
+            field(p)
         }
 
         Some(T!['}']) => {
@@ -54,8 +54,6 @@ pub(crate) fn field(p: &mut Parser) -> bool {
         }
         _ => guard.finish_node(),
     }
-
-    false
 }
 
 /// See: https://spec.graphql.org/October2021/#FieldsDefinition
diff --git a/crates/apollo-parser/src/parser/grammar/fragment.rs b/crates/apollo-parser/src/parser/grammar/fragment.rs
index f4e5844..f407a38 100644
--- a/crates/apollo-parser/src/parser/grammar/fragment.rs
+++ b/crates/apollo-parser/src/parser/grammar/fragment.rs
@@ -19,7 +19,7 @@ pub(crate) fn fragment_definition(p: &mut Parser) {
     }
 
     match p.peek() {
-        Some(T!['{']) => selection::selection_set(p),
+        Some(T!['{']) => selection::top_selection_set(p),
         _ => p.err("expected a Selection Set"),
     }
 }
@@ -77,7 +77,7 @@ pub(crate) fn inline_fragment(p: &mut Parser) {
     }
 
     match p.peek() {
-        Some(T!['{']) => selection::selection_set(p),
+        Some(T!['{']) => selection::top_selection_set(p),
         _ => p.err("expected Selection Set"),
     }
 }
diff --git a/crates/apollo-parser/src/parser/grammar/operation.rs b/crates/apollo-parser/src/parser/grammar/operation.rs
index 10ebc9e..561c350 100644
--- a/crates/apollo-parser/src/parser/grammar/operation.rs
+++ b/crates/apollo-parser/src/parser/grammar/operation.rs
@@ -61,13 +61,13 @@ pub(crate) fn operation_definition(p: &mut Parser) {
             }
 
             if let Some(T!['{']) = p.peek() {
-                selection::selection_set(p)
+                selection::top_selection_set(p)
             }
         }
         Some(T!['{']) => {
             let _g = p.start_node(SyntaxKind::OPERATION_DEFINITION);
 
-            selection::selection_set(p)
+            selection::top_selection_set(p)
         }
         _ => p.err_and_pop("expected an Operation Type or a Selection Set"),
     }
diff --git a/crates/apollo-parser/src/parser/grammar/selection.rs b/crates/apollo-parser/src/parser/grammar/selection.rs
index 826d2c7..c23c98f 100644
--- a/crates/apollo-parser/src/parser/grammar/selection.rs
+++ b/crates/apollo-parser/src/parser/grammar/selection.rs
@@ -3,14 +3,31 @@ use crate::{
     Parser, SyntaxKind, TokenKind, S, T,
 };
 
+/// In order to control recursion, we need to have a way to
+/// specify the "top" of a selection_set tree. This is the
+/// function which must be used to do this.
+pub(crate) fn top_selection_set(p: &mut Parser) {
+    p.recursion_limit.reset();
+    selection_set(p)
+}
+
 /// See: https://spec.graphql.org/October2021/#SelectionSet
 ///
 /// *SelectionSet*:
 ///     **{** Selection* **}**
 pub(crate) fn selection_set(p: &mut Parser) {
+    p.recursion_limit.consume();
+
     if let Some(T!['{']) = p.peek() {
         let _g = p.start_node(SyntaxKind::SELECTION_SET);
         p.bump(S!['{']);
+        // We need to enforce recursion limits to prevent
+        // excessive resource consumption or (more seriously)
+        // stack overflows.
+        if p.recursion_limit.limited() {
+            p.limit_err(format!("parser limit({}) reached", p.recursion_limit.limit));
+            return;
+        }
         selection(p);
         p.expect(T!['}'], S!['}']);
     }
@@ -24,10 +41,9 @@ pub(crate) fn selection_set(p: &mut Parser) {
 ///     InlineFragment
 pub(crate) fn selection(p: &mut Parser) {
     let mut has_selection = false;
-    let mut limit_exceeded = false;
 
     while let Some(node) = p.peek() {
-        if limit_exceeded {
+        if p.recursion_limit.limited() {
             break;
         }
         match node {
@@ -54,8 +70,7 @@ pub(crate) fn selection(p: &mut Parser) {
                 break;
             }
             TokenKind::Name => {
-                p.recursion_limit.reset();
-                limit_exceeded = field::field(p);
+                field::field(p);
                 has_selection = true;
             }
             _ => {
@@ -292,43 +307,118 @@ query SomeQuery(
     }
 
     #[test]
-    fn it_errors_when_field_selection_recursion_limit_exceeded() {
+    fn it_errors_when_selection_set_recursion_limit_exceeded() {
         let schema = r#"
-        query {Q1:product(id:1){url},Q2:product(id:2){url},Q3:product(id:3){url}}
+        query {
+          Q1 {
+            url
+          }
+        }
         "#;
-        let parser = Parser::with_recursion_limit(schema, 2);
+        let parser = Parser::with_recursion_limit(schema, 1);
 
         let ast = parser.parse();
 
         assert_eq!(ast.recursion_limit().high, 2);
         assert_eq!(ast.errors().len(), 1);
-        assert_eq!(ast.document().definitions().into_iter().count(), 1);
+        assert_eq!(ast.document().definitions().into_iter().count(), 2);
     }
 
     #[test]
-    fn it_passes_when_field_selection_recursion_limit_is_not_exceeded() {
+    fn it_passes_when_selection_set_recursion_limit_is_not_exceeded() {
         let schema = r#"
-        query {Q1:product(id:1){url},Q2:product(id:2){url},Q3:product(id:3){url}}
+        query {
+          Q1 {
+            url
+          }
+        }
         "#;
-        let parser = Parser::with_recursion_limit(schema, 3);
+        let parser = Parser::with_recursion_limit(schema, 7);
 
         let ast = parser.parse();
 
-        assert_eq!(ast.recursion_limit().high, 2);
+        assert_eq!(ast.recursion_limit().high, 4);
         assert_eq!(ast.errors().len(), 0);
         assert_eq!(ast.document().definitions().into_iter().count(), 1);
     }
 
     #[test]
-    fn it_passes_when_field_selection_recursion_limit_is_at_default() {
+    fn it_errors_when_selection_set_recursion_limit_is_exceeded_with_inline_fragment() {
         let schema = r#"
-            query {Q1:product(id:1){url},Q2:product(id:2){url},Q3:product(id:3){url}}
-            "#;
-        let parser = Parser::new(schema);
+        query {
+          ... on Page {
+            price
+            name
+          }
+        }
+        "#;
+        let parser = Parser::with_recursion_limit(schema, 2);
+
+        let ast = parser.parse();
+
+        assert_eq!(ast.recursion_limit().high, 3);
+        assert_eq!(ast.errors().len(), 1);
+        assert_eq!(ast.document().definitions().into_iter().count(), 1);
+    }
+
+    #[test]
+    fn it_errors_when_selection_set_recursion_limit_is_exceeded_fragment_spread() {
+        let schema = r#"
+        query {
+          product {
+            ...Page
+          }
+        }
+        "#;
+        let parser = Parser::with_recursion_limit(schema, 2);
+
+        let ast = parser.parse();
+
+        assert_eq!(ast.recursion_limit().high, 3);
+        assert_eq!(ast.errors().len(), 1);
+        assert_eq!(ast.document().definitions().into_iter().count(), 1);
+    }
+
+    #[test]
+    fn it_errors_when_selection_set_recursion_limit_is_exceeded_in_fragment_definition() {
+        let schema = r#"
+        query ExampleQuery {
+          topProducts {
+            name
+          }
+          ... multipleSubscriptions
+        }
+
+        fragment multipleSubscriptions on Subscription {
+          newMessage {
+            body
+            sender
+          }
+        }
+        "#;
+        let parser = Parser::with_recursion_limit(schema, 1);
 
         let ast = parser.parse();
 
         assert_eq!(ast.recursion_limit().high, 2);
+        assert_eq!(ast.errors().len(), 1);
+        assert_eq!(ast.document().definitions().into_iter().count(), 2);
+    }
+
+    #[test]
+    fn it_passes_when_selection_set_recursion_limit_is_at_default() {
+        let schema = r#"
+        query {
+          Q1 {
+            url
+          },
+        }
+        "#;
+        let parser = Parser::new(schema);
+
+        let ast = parser.parse();
+
+        assert_eq!(ast.recursion_limit().high, 4);
         assert_eq!(ast.errors().len(), 0);
         assert_eq!(ast.document().definitions().into_iter().count(), 1);
     }
diff --git a/crates/apollo-parser/src/parser/mod.rs b/crates/apollo-parser/src/parser/mod.rs
index 974d571..2df8a0e 100644
--- a/crates/apollo-parser/src/parser/mod.rs
+++ b/crates/apollo-parser/src/parser/mod.rs
@@ -380,7 +380,7 @@ impl LimitTracker {
     }
 
     fn limited(&self) -> bool {
-        self.current >= self.limit
+        self.current > self.limit
     }
 
     fn consume(&mut self) {


Test patch:
diff --git a/crates/apollo-compiler/test_data/ok/0001_annonymous_operation_definition.txt b/crates/apollo-compiler/test_data/ok/0001_annonymous_operation_definition.txt
index a6a6dc4..9ded15c 100644
--- a/crates/apollo-compiler/test_data/ok/0001_annonymous_operation_definition.txt
+++ b/crates/apollo-compiler/test_data/ok/0001_annonymous_operation_definition.txt
@@ -61,4 +61,4 @@
                         - IDENT@79..85 "String"
                 - WHITESPACE@85..86 "\n"
             - R_CURLY@86..87 "}"
-recursion limit: 4096, high: 1
+recursion limit: 4096, high: 4
diff --git a/crates/apollo-compiler/test_data/ok/0002_multiple_named_operation_definitions.txt b/crates/apollo-compiler/test_data/ok/0002_multiple_named_operation_definitions.txt
index c08e985..080b268 100644
--- a/crates/apollo-compiler/test_data/ok/0002_multiple_named_operation_definitions.txt
+++ b/crates/apollo-compiler/test_data/ok/0002_multiple_named_operation_definitions.txt
@@ -128,4 +128,4 @@
                 - WHITESPACE@214..215 "\n"
             - R_CURLY@215..216 "}"
             - WHITESPACE@216..217 "\n"
-recursion limit: 4096, high: 1
+recursion limit: 4096, high: 6
diff --git a/crates/apollo-parser/test_data/parser/err/0007_fragment_definition_with_invalid_fragment_name.txt b/crates/apollo-parser/test_data/parser/err/0007_fragment_definition_with_invalid_fragment_name.txt
index 20f0f5c..1882ea7 100644
--- a/crates/apollo-parser/test_data/parser/err/0007_fragment_definition_with_invalid_fragment_name.txt
+++ b/crates/apollo-parser/test_data/parser/err/0007_fragment_definition_with_invalid_fragment_name.txt
@@ -25,4 +25,4 @@
                     - WHITESPACE@34..35 "\n"
             - R_CURLY@35..36 "}"
 - ERROR@9:11 "Fragment Name cannot be 'on'" on
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0008_fragment_definition_with_invalid_type_condition.txt b/crates/apollo-parser/test_data/parser/err/0008_fragment_definition_with_invalid_type_condition.txt
index a24cd3c..bf2efd4 100644
--- a/crates/apollo-parser/test_data/parser/err/0008_fragment_definition_with_invalid_type_condition.txt
+++ b/crates/apollo-parser/test_data/parser/err/0008_fragment_definition_with_invalid_type_condition.txt
@@ -26,4 +26,4 @@
                     - WHITESPACE@44..45 "\n"
             - R_CURLY@45..46 "}"
 - ERROR@22:26 "exptected 'on'" User
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0025_document_with_incorrect_definition_and_selection_set.txt b/crates/apollo-parser/test_data/parser/err/0025_document_with_incorrect_definition_and_selection_set.txt
index 5e07fa5..206c96b 100644
--- a/crates/apollo-parser/test_data/parser/err/0025_document_with_incorrect_definition_and_selection_set.txt
+++ b/crates/apollo-parser/test_data/parser/err/0025_document_with_incorrect_definition_and_selection_set.txt
@@ -14,4 +14,4 @@
                     - WHITESPACE@25..26 "\n"
             - R_CURLY@26..27 "}"
 - ERROR@0:14 "expected definition" uasdf21230jkdw
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0026_invalid_definition_squished_between_two_valid_definitions.txt b/crates/apollo-parser/test_data/parser/err/0026_invalid_definition_squished_between_two_valid_definitions.txt
index a9d783d..2e72cdf 100644
--- a/crates/apollo-parser/test_data/parser/err/0026_invalid_definition_squished_between_two_valid_definitions.txt
+++ b/crates/apollo-parser/test_data/parser/err/0026_invalid_definition_squished_between_two_valid_definitions.txt
@@ -55,4 +55,4 @@
                     - WHITESPACE@124..125 "\n"
             - R_CURLY@125..126 "}"
 - ERROR@99:113 "expected definition" uasdf21230jkdw
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0029_operation_definition_with_empty_selection_set.txt b/crates/apollo-parser/test_data/parser/err/0029_operation_definition_with_empty_selection_set.txt
index e4f486d..303dd5b 100644
--- a/crates/apollo-parser/test_data/parser/err/0029_operation_definition_with_empty_selection_set.txt
+++ b/crates/apollo-parser/test_data/parser/err/0029_operation_definition_with_empty_selection_set.txt
@@ -7,4 +7,4 @@
             - L_CURLY@6..7 "{"
             - R_CURLY@7..8 "}"
 - ERROR@7:8 "expected at least one Selection in Selection Set" }
-recursion limit: 4096, high: 0
\ No newline at end of file
+recursion limit: 4096, high: 1
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0030_operation_definition_with_description.txt b/crates/apollo-parser/test_data/parser/err/0030_operation_definition_with_description.txt
index e16bc93..38ef317 100644
--- a/crates/apollo-parser/test_data/parser/err/0030_operation_definition_with_description.txt
+++ b/crates/apollo-parser/test_data/parser/err/0030_operation_definition_with_description.txt
@@ -12,4 +12,4 @@
             - R_CURLY@14..15 "}"
 - ERROR@0:93 "expected an Operation Type or a Selection Set" "after this PR this should not be an issue: https://github.com/graphql/graphql-spec/pull/892"
 - ERROR@107:108 "expected at least one Selection in Selection Set" }
-recursion limit: 4096, high: 0
\ No newline at end of file
+recursion limit: 4096, high: 1
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0031_argument_with_erronous_string_value.txt b/crates/apollo-parser/test_data/parser/err/0031_argument_with_erronous_string_value.txt
index c33a86c..d41a60e 100644
--- a/crates/apollo-parser/test_data/parser/err/0031_argument_with_erronous_string_value.txt
+++ b/crates/apollo-parser/test_data/parser/err/0031_argument_with_erronous_string_value.txt
@@ -18,4 +18,4 @@
             - R_CURLY@15..16 "}"
 - ERROR@13:25 "unexpected escaped character" "\string ID"
 - ERROR@25:26 "expected a valid Value" )
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0002_selection_simple.txt b/crates/apollo-parser/test_data/parser/ok/0002_selection_simple.txt
index ebb8ca9..8fb15ce 100644
--- a/crates/apollo-parser/test_data/parser/ok/0002_selection_simple.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0002_selection_simple.txt
@@ -12,4 +12,4 @@
                     - IDENT@14..23 "faveSnack"
                     - WHITESPACE@23..24 "\n"
             - R_CURLY@24..25 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0003_selection_with_fields.txt b/crates/apollo-parser/test_data/parser/ok/0003_selection_with_fields.txt
index ff2e4d7..2e98f2f 100644
--- a/crates/apollo-parser/test_data/parser/ok/0003_selection_with_fields.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0003_selection_with_fields.txt
@@ -56,4 +56,4 @@
                     - IDENT@168..177 "faveSnack"
                     - WHITESPACE@177..178 "\n"
             - R_CURLY@178..179 "}"
-recursion limit: 4096, high: 3
\ No newline at end of file
+recursion limit: 4096, high: 13
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0004_selection_with_fields_aliases_arguments.txt b/crates/apollo-parser/test_data/parser/ok/0004_selection_with_fields_aliases_arguments.txt
index 21af718..8379c63 100644
--- a/crates/apollo-parser/test_data/parser/ok/0004_selection_with_fields_aliases_arguments.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0004_selection_with_fields_aliases_arguments.txt
@@ -71,4 +71,4 @@
                     - R_PAREN@199..200 ")"
                     - WHITESPACE@200..201 "\n"
             - R_CURLY@201..202 "}"
-recursion limit: 4096, high: 3
\ No newline at end of file
+recursion limit: 4096, high: 13
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0005_selection_with_inline_fragments.txt b/crates/apollo-parser/test_data/parser/ok/0005_selection_with_inline_fragments.txt
index e11d0ba..ce14759 100644
--- a/crates/apollo-parser/test_data/parser/ok/0005_selection_with_inline_fragments.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0005_selection_with_inline_fragments.txt
@@ -40,4 +40,4 @@
                     - R_CURLY@88..89 "}"
                     - WHITESPACE@89..90 "\n"
             - R_CURLY@90..91 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 4
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0006_selection_with_fragment_spread.txt b/crates/apollo-parser/test_data/parser/ok/0006_selection_with_fragment_spread.txt
index d941ffb..cf36684 100644
--- a/crates/apollo-parser/test_data/parser/ok/0006_selection_with_fragment_spread.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0006_selection_with_fragment_spread.txt
@@ -113,4 +113,4 @@
                     - WHITESPACE@207..208 "\n"
             - R_CURLY@208..209 "}"
             - WHITESPACE@209..210 "\n"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0012_fragment_definition.txt b/crates/apollo-parser/test_data/parser/ok/0012_fragment_definition.txt
index 1a97fb5..c4be3ac 100644
--- a/crates/apollo-parser/test_data/parser/ok/0012_fragment_definition.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0012_fragment_definition.txt
@@ -45,4 +45,4 @@
                     - R_PAREN@80..81 ")"
                     - WHITESPACE@81..82 "\n"
             - R_CURLY@82..83 "}"
-recursion limit: 4096, high: 3
\ No newline at end of file
+recursion limit: 4096, high: 4
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0013_fragment_definition_with_fragment_spread.txt b/crates/apollo-parser/test_data/parser/ok/0013_fragment_definition_with_fragment_spread.txt
index 1c69bea..805fd1b 100644
--- a/crates/apollo-parser/test_data/parser/ok/0013_fragment_definition_with_fragment_spread.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0013_fragment_definition_with_fragment_spread.txt
@@ -31,4 +31,4 @@
                         - IDENT@55..73 "standardProfilePic"
                         - WHITESPACE@73..74 "\n"
             - R_CURLY@74..75 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0020_operation_type_definition.txt b/crates/apollo-parser/test_data/parser/ok/0020_operation_type_definition.txt
index 87d6210..aad74a2 100644
--- a/crates/apollo-parser/test_data/parser/ok/0020_operation_type_definition.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0020_operation_type_definition.txt
@@ -51,4 +51,4 @@
                     - IDENT@113..117 "lion"
                     - WHITESPACE@117..118 "\n"
             - R_CURLY@118..119 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 8
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0021_operation_type_definition_with_arguments.txt b/crates/apollo-parser/test_data/parser/ok/0021_operation_type_definition_with_arguments.txt
index 3469f8f..c2f9337 100644
--- a/crates/apollo-parser/test_data/parser/ok/0021_operation_type_definition_with_arguments.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0021_operation_type_definition_with_arguments.txt
@@ -41,4 +41,4 @@
                     - IDENT@65..70 "treat"
                     - WHITESPACE@70..71 "\n"
             - R_CURLY@71..72 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0022_operation_type_definition_with_arguments_and_directives.txt b/crates/apollo-parser/test_data/parser/ok/0022_operation_type_definition_with_arguments_and_directives.txt
index a9e78f1..083f277 100644
--- a/crates/apollo-parser/test_data/parser/ok/0022_operation_type_definition_with_arguments_and_directives.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0022_operation_type_definition_with_arguments_and_directives.txt
@@ -53,4 +53,4 @@
                     - IDENT@86..91 "treat"
                     - WHITESPACE@91..92 "\n"
             - R_CURLY@92..93 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0030_values.txt b/crates/apollo-parser/test_data/parser/ok/0030_values.txt
index a88851c..59b0505 100644
--- a/crates/apollo-parser/test_data/parser/ok/0030_values.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0030_values.txt
@@ -83,4 +83,4 @@
                     - R_PAREN@111..112 ")"
                     - WHITESPACE@112..113 "\n"
             - R_CURLY@113..114 "}"
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0031_variables_with_default.txt b/crates/apollo-parser/test_data/parser/ok/0031_variables_with_default.txt
index 846cfc1..577a24c 100644
--- a/crates/apollo-parser/test_data/parser/ok/0031_variables_with_default.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0031_variables_with_default.txt
@@ -50,4 +50,4 @@
                     - IDENT@66..72 "animal"
                     - WHITESPACE@72..73 "\n"
             - R_CURLY@73..74 "}"
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0034_query_shorthand_followed_by_fragment_definition.txt b/crates/apollo-parser/test_data/parser/ok/0034_query_shorthand_followed_by_fragment_definition.txt
index f4196fb..b332e13 100644
--- a/crates/apollo-parser/test_data/parser/ok/0034_query_shorthand_followed_by_fragment_definition.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0034_query_shorthand_followed_by_fragment_definition.txt
@@ -37,4 +37,4 @@
                     - IDENT@62..66 "name"
                     - WHITESPACE@66..67 "\n"
             - R_CURLY@67..68 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0035_query_with_variables.txt b/crates/apollo-parser/test_data/parser/ok/0035_query_with_variables.txt
index 4fef40e..43c371f 100644
--- a/crates/apollo-parser/test_data/parser/ok/0035_query_with_variables.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0035_query_with_variables.txt
@@ -27,4 +27,4 @@
                     - IDENT@27..31 "name"
                     - WHITESPACE@31..32 "\n"
             - R_CURLY@32..33 "}"
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0036_parses_variable_definition_with_list_type.txt b/crates/apollo-parser/test_data/parser/ok/0036_parses_variable_definition_with_list_type.txt
index 8a58a39..4e273d6 100644
--- a/crates/apollo-parser/test_data/parser/ok/0036_parses_variable_definition_with_list_type.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0036_parses_variable_definition_with_list_type.txt
@@ -44,4 +44,4 @@
                     - R_PAREN@57..58 ")"
                     - WHITESPACE@58..59 "\n"
             - R_CURLY@59..60 "}"
-recursion limit: 4096, high: 2
\ No newline at end of file
+recursion limit: 4096, high: 3
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0037_operation_type_definition_with_inline_fragment.txt b/crates/apollo-parser/test_data/parser/ok/0037_operation_type_definition_with_inline_fragment.txt
index 79b0bb7..a6e9457 100644
--- a/crates/apollo-parser/test_data/parser/ok/0037_operation_type_definition_with_inline_fragment.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0037_operation_type_definition_with_inline_fragment.txt
@@ -105,4 +105,4 @@
                     - R_CURLY@190..191 "}"
                     - WHITESPACE@191..192 "\n"
             - R_CURLY@192..193 "}"
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 4
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/ok/0039_variable_with_directives.txt b/crates/apollo-parser/test_data/parser/ok/0039_variable_with_directives.txt
index 73c27ad..a3bafa6 100644
--- a/crates/apollo-parser/test_data/parser/ok/0039_variable_with_directives.txt
+++ b/crates/apollo-parser/test_data/parser/ok/0039_variable_with_directives.txt
@@ -66,4 +66,4 @@
                     - IDENT@103..109 "animal"
                     - WHITESPACE@109..110 "\n"
             - R_CURLY@110..111 "}"
-recursion limit: 4096, high: 1
\ No newline at end of file
+recursion limit: 4096, high: 2
\ No newline at end of file