Skip to content

Commit

Permalink
WIP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cecton committed Dec 3, 2021
1 parent eb0f01f commit e6186ff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apollo-router-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 12 additions & 2 deletions apollo-router-core/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
.join(", "),
Expand Down Expand Up @@ -451,6 +450,7 @@ impl From<ast::OperationDefinition> 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()
Expand Down Expand Up @@ -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();
}
}
4 changes: 2 additions & 2 deletions apollo-router-core/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e6186ff

Please sign in to comment.