Skip to content

Commit

Permalink
fix(parser): selection set is required for named operation definitions (
Browse files Browse the repository at this point in the history
#301)

fixes #300
  • Loading branch information
lrlna authored Sep 20, 2022
1 parent b308fd0 commit cad615f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/apollo-parser/src/parser/grammar/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ pub(crate) fn operation_definition(p: &mut Parser) {
directive::directives(p);
}

if let Some(T!['{']) = p.peek() {
selection::top_selection_set(p)
match p.peek() {
Some(T!['{']) => selection::top_selection_set(p),
_ => p.err_and_pop("expected a Selection Set"),
}
}
Some(T!['{']) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
query __typename }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- DOCUMENT@0..17
- OPERATION_DEFINITION@0..17
- OPERATION_TYPE@0..6
- query_KW@0..5 "query"
- WHITESPACE@5..6 " "
- NAME@6..17
- IDENT@6..16 "__typename"
- WHITESPACE@16..17 " "
- ERROR@17:18 "expected a Selection Set" }
recursion limit: 4096, high: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
query __typename
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- DOCUMENT@0..16
- OPERATION_DEFINITION@0..16
- OPERATION_TYPE@0..6
- query_KW@0..5 "query"
- WHITESPACE@5..6 " "
- NAME@6..16
- IDENT@6..16 "__typename"
- ERROR@16:16 "expected a Selection Set" EOF
recursion limit: 4096, high: 0

0 comments on commit cad615f

Please sign in to comment.