Skip to content

Commit

Permalink
Fix for unifying object types
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoverton committed Mar 19, 2024
1 parent ff6b692 commit b07dc12
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/cli/src/introspection/sampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ async fn sample_schema_from_collection(
let mut collected_object_types = vec![];
while let Some(document) = cursor.try_next().await? {
let object_types = make_object_type(collection_name, &document)?;
collected_object_types = unify_object_types(collected_object_types, object_types)?;
collected_object_types = if collected_object_types.is_empty() {
object_types
} else {
unify_object_types(collected_object_types, object_types)?
};
}
let collection_info = Collection {
name: collection_name.to_string(),
Expand Down Expand Up @@ -124,7 +128,11 @@ fn make_field_type(
for elem in arr {
let (elem_collected_otds, elem_type) =
make_field_type(object_type_name, field_name, elem)?;
collected_otds = unify_object_types(collected_otds, elem_collected_otds)?;
collected_otds = if collected_otds.is_empty() {
elem_collected_otds
} else {
unify_object_types(collected_otds, elem_collected_otds)?
};
let context = TypeUnificationContext::new(object_type_name, field_name);
result_type = unify_type(context, result_type, elem_type)?;
}
Expand Down

0 comments on commit b07dc12

Please sign in to comment.