Skip to content

Commit

Permalink
fix: detect findUniqueOrThrow as a compactable findUnique operation
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Jun 1, 2023
1 parent 282e4b4 commit c3919c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ mod compound_batch {
]).await?;
assert!(doc.is_compact());

// COMPACT: Queries use compound uniqueOrThrow
let doc = compact_batch(&runner, vec![
r#"query {findUniqueArtistOrThrow(where:{firstName_lastName:{firstName:"Musti",lastName:"Naukio"}}) {firstName lastName}}"#.to_string(),
r#"query {findUniqueArtistOrThrow(where:{firstName_lastName:{firstName:"NO",lastName:"AVAIL"}}) {firstName lastName}}"#.to_string(),
]).await?;
assert!(doc.is_compact());

// COMPACT: Queries use compound unique + non unique equal filter (shorthand syntax)
let doc = compact_batch(&runner, vec![
r#"query {findUniqueArtist(where:{firstName_lastName:{firstName:"Musti",lastName:"Naukio"}, non_unique: 0}) {firstName lastName}}"#.to_string(),
Expand Down
5 changes: 4 additions & 1 deletion query-engine/schema/src/output_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ impl<'a> OutputField<'a> {
}

pub fn is_find_unique(&self) -> bool {
matches!(self.query_tag(), Some(&QueryTag::FindUnique))
matches!(
self.query_tag(),
Some(&QueryTag::FindUnique | QueryTag::FindUniqueOrThrow)
)
}

/// Relevant for resolving top level queries.
Expand Down

0 comments on commit c3919c6

Please sign in to comment.