mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
rename function to be clearer (#405)
<!-- Thank you for submitting this PR! :) --> ## Description `check_conflicting_graphql_types` actually inserts a new GraphQL type into a set (and explodes on failure). Renamed to `store_new_graphql_type` which I feel is a bit clearer. V3_GIT_ORIGIN_REV_ID: 4b774b9cd9e479c16f3de8af4df263f97cfab107
This commit is contained in:
parent
ec9a3aabc1
commit
6881852b43
@ -22,7 +22,7 @@ use crate::metadata::resolved::model::{
|
||||
};
|
||||
use crate::metadata::resolved::relationship::resolve_relationship;
|
||||
use crate::metadata::resolved::types::{
|
||||
check_conflicting_graphql_types, mk_name, resolve_object_type, resolve_output_type_permission,
|
||||
mk_name, resolve_object_type, resolve_output_type_permission, store_new_graphql_type,
|
||||
TypeRepresentation,
|
||||
};
|
||||
|
||||
@ -428,7 +428,7 @@ fn resolve_scalar_types(
|
||||
name: qualified_scalar_type_name,
|
||||
});
|
||||
}
|
||||
check_conflicting_graphql_types(existing_graphql_types, graphql_type_name.as_ref())?;
|
||||
store_new_graphql_type(existing_graphql_types, graphql_type_name.as_ref())?;
|
||||
}
|
||||
Ok(scalar_types)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use crate::metadata::resolved::subgraph::{
|
||||
serialize_qualified_btreemap, ArgumentInfo, Qualified, QualifiedBaseType,
|
||||
QualifiedTypeReference,
|
||||
};
|
||||
use crate::metadata::resolved::types::check_conflicting_graphql_types;
|
||||
use crate::metadata::resolved::types::store_new_graphql_type;
|
||||
use crate::metadata::resolved::types::{mk_name, FieldDefinition, TypeMapping};
|
||||
use crate::metadata::resolved::types::{ScalarTypeInfo, TypeRepresentation};
|
||||
use crate::schema::types::output_type::relationship::{
|
||||
@ -998,7 +998,7 @@ pub fn resolve_model_graphql_api(
|
||||
Some(type_name) => mk_name(type_name.0.as_str()).map(ast::TypeName).map(Some),
|
||||
}?;
|
||||
// TODO: (paritosh) should we check for conflicting graphql types for default order_by type name as well?
|
||||
check_conflicting_graphql_types(
|
||||
store_new_graphql_type(
|
||||
existing_graphql_types,
|
||||
order_by_expression_type_name.as_ref(),
|
||||
)?;
|
||||
@ -1203,10 +1203,7 @@ pub fn resolve_model_graphql_api(
|
||||
None => Ok(None),
|
||||
Some(type_name) => mk_name(type_name.0.as_str()).map(ast::TypeName).map(Some),
|
||||
}?;
|
||||
check_conflicting_graphql_types(
|
||||
existing_graphql_types,
|
||||
arguments_input_type_name.as_ref(),
|
||||
)?;
|
||||
store_new_graphql_type(existing_graphql_types, arguments_input_type_name.as_ref())?;
|
||||
|
||||
if let Some(type_name) = arguments_input_type_name {
|
||||
let argument_input_field_name = graphql_config
|
||||
|
@ -145,7 +145,9 @@ pub struct ResolvedApolloFederationObjectKey {
|
||||
pub fields: nonempty::NonEmpty<FieldName>,
|
||||
}
|
||||
|
||||
pub fn check_conflicting_graphql_types(
|
||||
/// try to add `new_graphql_type` to `existing_graphql_types`, returning an error
|
||||
/// if there is a name conflict
|
||||
pub fn store_new_graphql_type(
|
||||
existing_graphql_types: &mut HashSet<ast::TypeName>,
|
||||
new_graphql_type: Option<&ast::TypeName>,
|
||||
) -> Result<(), Error> {
|
||||
@ -292,8 +294,8 @@ pub fn resolve_object_type(
|
||||
))
|
||||
}
|
||||
}?;
|
||||
check_conflicting_graphql_types(existing_graphql_types, graphql_type_name.as_ref())?;
|
||||
check_conflicting_graphql_types(existing_graphql_types, graphql_input_type_name.as_ref())?;
|
||||
store_new_graphql_type(existing_graphql_types, graphql_type_name.as_ref())?;
|
||||
store_new_graphql_type(existing_graphql_types, graphql_input_type_name.as_ref())?;
|
||||
|
||||
Ok(TypeRepresentation::Object(ObjectTypeRepresentation {
|
||||
fields: resolved_fields,
|
||||
@ -598,10 +600,7 @@ pub(crate) fn resolve_object_boolean_expression_type(
|
||||
.map(|graphql_config| {
|
||||
let graphql_type_name =
|
||||
mk_name(graphql_config.type_name.0.as_ref()).map(ast::TypeName)?;
|
||||
check_conflicting_graphql_types(
|
||||
existing_graphql_types,
|
||||
Some(&graphql_type_name),
|
||||
)?;
|
||||
store_new_graphql_type(existing_graphql_types, Some(&graphql_type_name))?;
|
||||
Ok::<_, Error>(ObjectBooleanExpressionTypeGraphQlConfiguration {
|
||||
type_name: graphql_type_name,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user