Repository: apollographql/apollo-rs (rust)

Issue:
selection set is required for named operation definitions
The parser doesn't produce any errors for missing selection sets in named operation definitions such as
```graphql
query __typename {
```
or
```graphql
query namedQuery
```

Pull request description:
fix(parser): selection set is required for named operation definitions
The parser was not creating errors for missing selection sets. fixes #300 

Patch:
diff --git a/crates/apollo-parser/src/parser/grammar/operation.rs b/crates/apollo-parser/src/parser/grammar/operation.rs
index 561c350..f333da7 100644
--- a/crates/apollo-parser/src/parser/grammar/operation.rs
+++ b/crates/apollo-parser/src/parser/grammar/operation.rs
@@ -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!['{']) => {


Test patch:
diff --git a/crates/apollo-parser/test_data/parser/err/0040_operation_definition_missing_selection_set.graphql b/crates/apollo-parser/test_data/parser/err/0040_operation_definition_missing_selection_set.graphql
new file mode 100644
index 0000000..f72e897
--- /dev/null
+++ b/crates/apollo-parser/test_data/parser/err/0040_operation_definition_missing_selection_set.graphql
@@ -0,0 +1,1 @@
+query __typename }
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0040_operation_definition_missing_selection_set.txt b/crates/apollo-parser/test_data/parser/err/0040_operation_definition_missing_selection_set.txt
new file mode 100644
index 0000000..0a25e6d
--- /dev/null
+++ b/crates/apollo-parser/test_data/parser/err/0040_operation_definition_missing_selection_set.txt
@@ -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
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0041_operation_definition_with_missing_selection_set.graphql b/crates/apollo-parser/test_data/parser/err/0041_operation_definition_with_missing_selection_set.graphql
new file mode 100644
index 0000000..d1f42f3
--- /dev/null
+++ b/crates/apollo-parser/test_data/parser/err/0041_operation_definition_with_missing_selection_set.graphql
@@ -0,0 +1,1 @@
+query __typename
\ No newline at end of file
diff --git a/crates/apollo-parser/test_data/parser/err/0041_operation_definition_with_missing_selection_set.txt b/crates/apollo-parser/test_data/parser/err/0041_operation_definition_with_missing_selection_set.txt
new file mode 100644
index 0000000..4f6eee0
--- /dev/null
+++ b/crates/apollo-parser/test_data/parser/err/0041_operation_definition_with_missing_selection_set.txt
@@ -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
\ No newline at end of file