diff --git a/Cargo.lock b/Cargo.lock index 12a44c0ee95..c1d4f534442 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,7 +70,7 @@ checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "apollo-parser" version = "0.1.0" -source = "git+https://github.com/apollographql/apollo-rs.git?rev=6e8e8a8b23c5489fdb2154029488dfcfe9cba80a#6e8e8a8b23c5489fdb2154029488dfcfe9cba80a" +source = "git+https://github.com/apollographql/apollo-rs.git?rev=95f894632b6383c5c4febe5bc8dd0fcbd5576cfe#95f894632b6383c5c4febe5bc8dd0fcbd5576cfe" dependencies = [ "rowan", ] diff --git a/apollo-router-core/Cargo.toml b/apollo-router-core/Cargo.toml index 37bc29f63d3..6af52382fce 100644 --- a/apollo-router-core/Cargo.toml +++ b/apollo-router-core/Cargo.toml @@ -12,7 +12,7 @@ license-file = "./LICENSE" failfast = [] [dependencies] -apollo-parser = { git = "https://github.com/apollographql/apollo-rs.git", rev = "6e8e8a8b23c5489fdb2154029488dfcfe9cba80a" } +apollo-parser = { git = "https://github.com/apollographql/apollo-rs.git", rev = "95f894632b6383c5c4febe5bc8dd0fcbd5576cfe" } async-trait = "0.1.51" derivative = "2.2.0" displaydoc = "0.2" diff --git a/apollo-router-core/src/query.rs b/apollo-router-core/src/query.rs index c78edff1029..28270ad538c 100644 --- a/apollo-router-core/src/query.rs +++ b/apollo-router-core/src/query.rs @@ -63,11 +63,10 @@ impl Query { let parser = apollo_parser::Parser::new(string.as_str()); let tree = parser.parse(); - if !tree.errors().is_empty() { + if tree.errors().next().is_some() { failfast_debug!( "Parsing error(s): {}", tree.errors() - .iter() .map(|err| format!("{:?}", err)) .collect::>() .join(", "), @@ -451,6 +450,7 @@ impl From for Operation { .expect("the node Name is not optional in the spec; qed") .text() .to_string(); + todo!("{:?}", definition.ty()); let ty = FieldType::from( definition .ty() @@ -859,4 +859,14 @@ mod tests { query.format_response(&mut response, Some("MyOperation")); assert_eq_and_ordered!(response.data, json! {{ "foo": "1" }}); } + + #[test] + fn variable_validation() { + let schema: Schema = "".parse().unwrap(); + let request = Request::builder() + .variables(Object::new()) + .query("query Foo($bar:Int){name}") + .build(); + let query = Query::parse(&request.query, &schema).unwrap(); + } } diff --git a/apollo-router-core/src/schema.rs b/apollo-router-core/src/schema.rs index 6f4e7c97613..524f61e0a6e 100644 --- a/apollo-router-core/src/schema.rs +++ b/apollo-router-core/src/schema.rs @@ -17,8 +17,8 @@ impl std::str::FromStr for Schema { let parser = apollo_parser::Parser::new(s); let tree = parser.parse(); - if !tree.errors().is_empty() { - return Err(SchemaError::ParseErrors(tree.errors().to_vec())); + if tree.errors().next().is_some() { + return Err(SchemaError::ParseErrors(tree.errors().cloned().collect())); } let document = tree.document();