Skip to content

Commit

Permalink
Add a test for operation field type resolution v.s. type extensions
Browse files Browse the repository at this point in the history
This type resolution in apollographql/router#2710
was the motivation to start work on
#468
  • Loading branch information
SimonSapin committed Mar 24, 2023
1 parent 4ba24f5 commit 3692e06
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/apollo-compiler/src/database/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,20 @@ mod tests {
assert!(!union_.has_member("Enum"));
}

#[test]
fn query_extended_type() {
let mut compiler = ApolloCompiler::new();
compiler.add_type_system("type Query { foo: String }", "base.graphql");
compiler.add_type_system("extend type Query { bar: Int }", "ext.graphql");
compiler.add_executable("{ bar }", "query.graphql");
let operations = compiler.db.all_operations();
let fields = operations[0].fields(&compiler.db);
// This unwrap failed before https://github.com/apollographql/apollo-rs/pull/482
// changed the behavior of `ObjectTypeDefinition::field(name)` in `hir_db::parent_ty`
let ty = fields[0].ty(&compiler.db).unwrap();
assert_eq!(ty.name(), "Int");
}

#[test]
fn syntax_errors() {
let mut compiler = ApolloCompiler::new();
Expand Down

0 comments on commit 3692e06

Please sign in to comment.