Skip to content

Commit

Permalink
style: cargo fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Inacio <[email protected]>
  • Loading branch information
gusinacio committed Mar 26, 2024
1 parent 8d05b49 commit 0a94318
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
7 changes: 3 additions & 4 deletions graph/src/data/graphql/queryable_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ impl<'a> QueryableType<'a> {
match self {
QueryableType::Object(o) => o.name == typename,
QueryableType::Interface(s::InterfaceType { name, .. })
| QueryableType::Union(s::UnionType { name, .. }) => types_for_interface
[name.as_str()]
.iter()
.any(|o| o.name == typename),
| QueryableType::Union(s::UnionType { name, .. }) => types_for_interface[name.as_str()]
.iter()
.any(|o| o.name == typename),
}
}

Expand Down
2 changes: 1 addition & 1 deletion graph/src/schema/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use graphql_parser::Pos;
use inflector::Inflector;
use lazy_static::lazy_static;

use crate::data::graphql::{QueryableType, ObjectTypeExt};
use crate::data::graphql::{ObjectTypeExt, QueryableType};
use crate::data::store::IdType;
use crate::schema::{
ast, META_FIELD_NAME, META_FIELD_TYPE, SQL_FIELD_NAME, SQL_FIELD_TYPE, SQL_INPUT_TYPE,
Expand Down
3 changes: 2 additions & 1 deletion graph/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ impl Schema {
// fully validated. The code should be changed to make sure that a
// `Schema` is always fully valid
pub fn new(id: DeploymentHash, document: s::Document) -> Result<Self, SchemaValidationError> {
let (interfaces_for_type, types_for_interface_or_union) = Self::collect_interfaces(&document)?;
let (interfaces_for_type, types_for_interface_or_union) =
Self::collect_interfaces(&document)?;

let mut schema = Schema {
id: id.clone(),
Expand Down
37 changes: 16 additions & 21 deletions graphql/src/store/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ pub(crate) fn build_query<'a>(
vec![(entity_type, selected_columns)]
}
QueryableType::Interface(s::InterfaceType { name, .. })
| QueryableType::Union(s::UnionType { name, .. }) => {
types_for_interface_or_union[name]
.iter()
.map(|o| {
let selected_columns = column_names.get(o);
let entity_type = schema.input.entity_type(o).unwrap();
(entity_type, selected_columns)
})
.collect()
}
| QueryableType::Union(s::UnionType { name, .. }) => types_for_interface_or_union[name]
.iter()
.map(|o| {
let selected_columns = column_names.get(o);
let entity_type = schema.input.entity_type(o).unwrap();
(entity_type, selected_columns)
})
.collect(),
});
let mut query = EntityQuery::new(parse_subgraph_id(entity)?, block, entity_types)
.range(build_range(field, max_first, max_skip)?);
Expand Down Expand Up @@ -579,14 +577,13 @@ fn build_order_by(
// In the case of an interface, we need to find the field on one of the types that implement the interface,
// as the `@derivedFrom` directive is only allowed on object types.
let field = match entity {
QueryableType::Object(_) => {
sast::get_field(entity, parent_field_name.as_str()).ok_or_else(|| {
QueryableType::Object(_) => sast::get_field(entity, parent_field_name.as_str())
.ok_or_else(|| {
QueryExecutionError::EntityFieldError(
entity.name().to_owned(),
parent_field_name.clone(),
)
})?
}
})?,
QueryableType::Interface(_) | QueryableType::Union(_) => {
let object_types = schema
.api
Expand Down Expand Up @@ -643,13 +640,11 @@ fn build_order_by(
};

let child = match child_entity {
QueryableType::Object(_) => {
OrderByChild::Object(ObjectOrderDetails {
entity_type: schema.input.entity_type(base_type)?,
join_attribute,
derived,
})
}
QueryableType::Object(_) => OrderByChild::Object(ObjectOrderDetails {
entity_type: schema.input.entity_type(base_type)?,
join_attribute,
derived,
}),
QueryableType::Interface(s::InterfaceType { name, .. })
| QueryableType::Union(s::UnionType { name, .. }) => {
let entity_types = schema
Expand Down

0 comments on commit 0a94318

Please sign in to comment.