mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-11 10:46:25 +03:00
Replace HashMap / HashSet with BTreeMap / BTreeSet in metadata-resolve
(#568)
<!-- Thank you for submitting this PR! :) --> ## Description We're adding some tests that compare the output of metadata resolve. Unfortunately, the results are nondeterministic because we use `HashMap` / `HashSet` in a lot of places. This replaces those uses with `BTreeMap` and `BTreeSet` in `metadata-resolve`, and in a few places in `schema` that rely on those types. Some light reading around suggests that as well as giving us consistent ordering, `BTree-` versions are better in terms of memory usage, esp with < 1000 items (which I'm pretty sure most metadata items are) https://www.reddit.com/r/rust/comments/xbkuc7/btreemap_vs_hashmap/ https://users.rust-lang.org/t/hashmap-vs-btreemap/13804/2 https://iq.opengenus.org/hashmap-and-btreemap-rust/ Functional no-op. V3_GIT_ORIGIN_REV_ID: dbf49aefef0cd7084a3a37ef4fe9fc61257e1305
This commit is contained in:
parent
0e2eb62874
commit
6710a5cf78
@ -24,7 +24,7 @@ use open_dds::models::ModelName;
|
||||
use open_dds::permissions;
|
||||
use open_dds::types::{CustomTypeName, FieldName, OperatorName};
|
||||
use ref_cast::RefCast;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
@ -64,33 +64,33 @@ pub enum ArgumentMappingError {
|
||||
|
||||
pub fn get_argument_mappings<'a>(
|
||||
arguments: &'a IndexMap<ArgumentName, ArgumentInfo>,
|
||||
argument_mapping: &HashMap<ArgumentName, String>,
|
||||
argument_mapping: &BTreeMap<ArgumentName, String>,
|
||||
ndc_arguments: &'a BTreeMap<String, ndc_models::ArgumentInfo>,
|
||||
object_types: &'a HashMap<
|
||||
object_types: &'a BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
type_permissions::ObjectTypeWithPermissions,
|
||||
>,
|
||||
scalar_types: &'a HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &'a HashMap<
|
||||
scalar_types: &'a BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &'a BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
) -> Result<
|
||||
(
|
||||
HashMap<ArgumentName, models::ConnectorArgumentName>,
|
||||
BTreeMap<ArgumentName, models::ConnectorArgumentName>,
|
||||
Vec<type_mappings::TypeMappingToCollect<'a>>,
|
||||
),
|
||||
ArgumentMappingError,
|
||||
> {
|
||||
let mut unconsumed_argument_mappings: HashMap<&ArgumentName, &models::ConnectorArgumentName> =
|
||||
HashMap::from_iter(
|
||||
let mut unconsumed_argument_mappings: BTreeMap<&ArgumentName, &models::ConnectorArgumentName> =
|
||||
BTreeMap::from_iter(
|
||||
argument_mapping
|
||||
.iter()
|
||||
.map(|(k, v)| (k, models::ConnectorArgumentName::ref_cast(v))),
|
||||
);
|
||||
|
||||
let mut resolved_argument_mappings =
|
||||
HashMap::<ArgumentName, models::ConnectorArgumentName>::new();
|
||||
BTreeMap::<ArgumentName, models::ConnectorArgumentName>::new();
|
||||
|
||||
let mut type_mappings_to_collect = Vec::<type_mappings::TypeMappingToCollect>::new();
|
||||
|
||||
@ -187,9 +187,9 @@ pub(crate) fn resolve_value_expression_for_argument(
|
||||
value_expression: &open_dds::permissions::ValueExpression,
|
||||
argument_type: &QualifiedTypeReference,
|
||||
subgraph: &str,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -284,8 +284,8 @@ pub(crate) fn resolve_model_predicate_with_type(
|
||||
data_connector_name: &Qualified<DataConnectorName>,
|
||||
subgraph: &str,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
|
||||
models: &IndexMap<Qualified<ModelName>, models::Model>,
|
||||
fields: &IndexMap<FieldName, object_types::FieldDefinition>,
|
||||
@ -650,7 +650,7 @@ fn resolve_binary_operator_for_type(
|
||||
data_connector: &Qualified<DataConnectorName>,
|
||||
field_name: &FieldName,
|
||||
fields: &IndexMap<FieldName, object_types::FieldDefinition>,
|
||||
scalars: &HashMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
scalars: &BTreeMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
ndc_scalar_type: &ndc_models::ScalarType,
|
||||
subgraph: &str,
|
||||
) -> Result<(String, QualifiedTypeReference), Error> {
|
||||
@ -692,11 +692,11 @@ fn resolve_binary_operator_for_type(
|
||||
}
|
||||
|
||||
fn remove_object_relationships(
|
||||
object_types_with_relationships: &HashMap<
|
||||
object_types_with_relationships: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
relationships::ObjectTypeWithRelationships,
|
||||
>,
|
||||
) -> HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions> {
|
||||
) -> BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions> {
|
||||
object_types_with_relationships
|
||||
.iter()
|
||||
.map(
|
||||
|
@ -9,13 +9,13 @@ use crate::types::subgraph::{
|
||||
use ndc_models;
|
||||
|
||||
use open_dds::data_connector::DataConnectorName;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
// helper function to resolve ndc types to dds type based on scalar type representations
|
||||
pub(crate) fn resolve_ndc_type(
|
||||
data_connector: &Qualified<DataConnectorName>,
|
||||
source_type: &ndc_models::Type,
|
||||
scalars: &HashMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
scalars: &BTreeMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
subgraph: &str,
|
||||
) -> Result<QualifiedTypeReference, Error> {
|
||||
match source_type {
|
||||
|
@ -8,7 +8,7 @@ use open_dds::data_connector::{DataConnectorName, DataConnectorObjectType};
|
||||
use open_dds::types::{CustomTypeName, FieldName};
|
||||
|
||||
use ref_cast::RefCast;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TypeMappingToCollect<'a> {
|
||||
@ -48,8 +48,8 @@ pub enum TypeMappingCollectionError {
|
||||
pub(crate) fn collect_type_mapping_for_source(
|
||||
mapping_to_collect: &TypeMappingToCollect,
|
||||
data_connector_name: &Qualified<DataConnectorName>,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
collected_mappings: &mut BTreeMap<Qualified<CustomTypeName>, object_types::TypeMapping>,
|
||||
) -> Result<(), TypeMappingCollectionError> {
|
||||
match object_types.get(mapping_to_collect.type_name) {
|
||||
|
@ -8,7 +8,7 @@ use lang_graphql::ast::common as ast;
|
||||
|
||||
use open_dds::types::CustomTypeName;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash, Default)]
|
||||
@ -20,7 +20,7 @@ pub struct NdcColumnForComparison {
|
||||
/// 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>,
|
||||
existing_graphql_types: &mut BTreeSet<ast::TypeName>,
|
||||
new_graphql_type: Option<&ast::TypeName>,
|
||||
) -> Result<(), Error> {
|
||||
if let Some(new_graphql_type) = new_graphql_type {
|
||||
@ -47,9 +47,9 @@ pub enum TypeRepresentation<'a, ObjectType> {
|
||||
/// `object_boolean_expression_types`
|
||||
pub fn get_type_representation<'a, ObjectType>(
|
||||
custom_type_name: &Qualified<CustomTypeName>,
|
||||
object_types: &'a HashMap<Qualified<CustomTypeName>, ObjectType>,
|
||||
scalar_types: &'a HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &'a HashMap<
|
||||
object_types: &'a BTreeMap<Qualified<CustomTypeName>, ObjectType>,
|
||||
scalar_types: &'a BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &'a BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -76,7 +76,7 @@ pub fn get_type_representation<'a, ObjectType>(
|
||||
|
||||
pub(crate) fn get_object_type_for_boolean_expression<'a>(
|
||||
object_boolean_expression_type: &boolean_expressions::ObjectBooleanExpressionType,
|
||||
object_types: &'a HashMap<
|
||||
object_types: &'a BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
relationships::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -95,7 +95,7 @@ pub(crate) fn get_object_type_for_boolean_expression<'a>(
|
||||
// check that `custom_type_name` exists in `object_types`
|
||||
pub fn object_type_exists<ObjectType>(
|
||||
custom_type_name: &Qualified<CustomTypeName>,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, ObjectType>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, ObjectType>,
|
||||
) -> Result<Qualified<CustomTypeName>, Error> {
|
||||
object_types
|
||||
.get(custom_type_name)
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use open_dds::{models::ModelName, types::CustomTypeName};
|
||||
|
||||
@ -11,8 +11,8 @@ use crate::types::subgraph::Qualified;
|
||||
/// Ideally, we could move more Apollo-based resolving into this discreet step, haven't
|
||||
/// investigated this too deeply yet.
|
||||
pub fn resolve(
|
||||
global_id_enabled_types: &HashMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
apollo_federation_entity_enabled_types: &HashMap<
|
||||
global_id_enabled_types: &BTreeMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
apollo_federation_entity_enabled_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
Option<Qualified<open_dds::models::ModelName>>,
|
||||
>,
|
||||
|
@ -12,7 +12,7 @@ use crate::types::subgraph::Qualified;
|
||||
use crate::helpers::type_mappings;
|
||||
use lang_graphql::ast::common as ast;
|
||||
use open_dds::types::CustomTypeName;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
pub use types::{
|
||||
BooleanExpressionGraphqlConfig, BooleanExpressionInfo, BooleanExpressionsOutput,
|
||||
ComparisonExpressionInfo, ObjectBooleanExpressionType,
|
||||
@ -22,12 +22,12 @@ pub use types::{
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
existing_graphql_types: &HashSet<ast::TypeName>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
||||
graphql_config: &graphql_config::GraphqlConfig,
|
||||
) -> Result<BooleanExpressionsOutput, Error> {
|
||||
let mut object_boolean_expression_types = HashMap::new();
|
||||
let mut object_boolean_expression_types = BTreeMap::new();
|
||||
let mut graphql_types = existing_graphql_types.clone();
|
||||
|
||||
for open_dds::accessor::QualifiedObject {
|
||||
@ -66,9 +66,9 @@ pub(crate) fn resolve_object_boolean_expression_type(
|
||||
object_boolean_expression: &open_dds::types::ObjectBooleanExpressionTypeV1,
|
||||
subgraph: &str,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
existing_graphql_types: &mut HashSet<ast::TypeName>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
existing_graphql_types: &mut BTreeSet<ast::TypeName>,
|
||||
graphql_config: &graphql_config::GraphqlConfig,
|
||||
) -> Result<ObjectBooleanExpressionType, Error> {
|
||||
// name of the boolean expression
|
||||
@ -272,7 +272,7 @@ pub fn resolve_boolean_expression_info(
|
||||
type_mappings: &object_types::TypeMapping,
|
||||
graphql_config: &graphql_config::GraphqlConfig,
|
||||
) -> Result<BooleanExpressionInfo, Error> {
|
||||
let mut scalar_fields = HashMap::new();
|
||||
let mut scalar_fields = BTreeMap::new();
|
||||
|
||||
let scalar_types = &data_connectors
|
||||
.data_connectors_with_scalars
|
||||
|
@ -1,11 +1,11 @@
|
||||
use crate::stages::{data_connectors, object_types};
|
||||
|
||||
use crate::types::subgraph::{Qualified, QualifiedTypeReference};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use lang_graphql::ast::common::{self as ast};
|
||||
use open_dds::data_connector::DataConnectorObjectType;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use open_dds::{
|
||||
data_connector::DataConnectorName,
|
||||
@ -15,8 +15,8 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
pub struct BooleanExpressionsOutput {
|
||||
pub object_boolean_expression_types:
|
||||
HashMap<Qualified<CustomTypeName>, ObjectBooleanExpressionType>,
|
||||
pub graphql_types: HashSet<ast::TypeName>,
|
||||
BTreeMap<Qualified<CustomTypeName>, ObjectBooleanExpressionType>,
|
||||
pub graphql_types: BTreeSet<ast::TypeName>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -52,6 +52,6 @@ pub struct BooleanExpressionGraphqlConfig {
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct BooleanExpressionInfo {
|
||||
pub type_name: ast::TypeName,
|
||||
pub scalar_fields: HashMap<FieldName, ComparisonExpressionInfo>,
|
||||
pub scalar_fields: BTreeMap<FieldName, ComparisonExpressionInfo>,
|
||||
pub graphql_config: BooleanExpressionGraphqlConfig,
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hasura_authn_core::Role;
|
||||
use indexmap::IndexMap;
|
||||
@ -25,7 +24,7 @@ use crate::helpers::typecheck;
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CommandWithPermissions {
|
||||
pub command: commands::Command,
|
||||
pub permissions: HashMap<Role, CommandPermission>,
|
||||
pub permissions: BTreeMap<Role, CommandPermission>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -38,9 +37,9 @@ pub struct CommandPermission {
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
commands: &IndexMap<Qualified<CommandName>, commands::Command>,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -55,7 +54,7 @@ pub fn resolve(
|
||||
command_name.clone(),
|
||||
CommandWithPermissions {
|
||||
command: command.clone(),
|
||||
permissions: HashMap::new(),
|
||||
permissions: BTreeMap::new(),
|
||||
},
|
||||
)
|
||||
})
|
||||
@ -95,17 +94,17 @@ pub fn resolve(
|
||||
pub fn resolve_command_permissions(
|
||||
command: &commands::Command,
|
||||
permissions: &CommandPermissionsV1,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
models: &IndexMap<Qualified<ModelName>, models::Model>,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
subgraph: &str,
|
||||
) -> Result<HashMap<Role, CommandPermission>, Error> {
|
||||
let mut validated_permissions = HashMap::new();
|
||||
) -> Result<BTreeMap<Role, CommandPermission>, Error> {
|
||||
let mut validated_permissions = BTreeMap::new();
|
||||
for command_permission in &permissions.permissions {
|
||||
let mut argument_presets = BTreeMap::new();
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub use types::{Command, CommandGraphQlApi, CommandSource};
|
||||
|
||||
use open_dds::types::{BaseType, CustomTypeName, TypeName, TypeReference};
|
||||
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::helpers::type_mappings;
|
||||
|
||||
@ -28,9 +28,9 @@ use crate::helpers::type_mappings;
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -75,9 +75,9 @@ pub fn resolve(
|
||||
fn type_exists(
|
||||
type_obj: &TypeReference,
|
||||
subgraph: &str,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -111,9 +111,9 @@ fn type_exists(
|
||||
pub fn resolve_command(
|
||||
command: &CommandV1,
|
||||
subgraph: &str,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -185,9 +185,9 @@ pub fn resolve_command_source(
|
||||
command: &mut Command,
|
||||
subgraph: &str,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
|
@ -11,7 +11,7 @@ use open_dds::commands::{CommandName, DataConnectorCommand, GraphQlRootFieldKind
|
||||
|
||||
use open_dds::types::{CustomTypeName, Deprecated};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CommandGraphQlApi {
|
||||
@ -29,7 +29,7 @@ pub struct CommandSource {
|
||||
deserialize_with = "deserialize_qualified_btreemap"
|
||||
)]
|
||||
pub type_mappings: BTreeMap<Qualified<CustomTypeName>, object_types::TypeMapping>,
|
||||
pub argument_mappings: HashMap<ArgumentName, models::ConnectorArgumentName>,
|
||||
pub argument_mappings: BTreeMap<ArgumentName, models::ConnectorArgumentName>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
pub mod types;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
pub use types::{
|
||||
DataConnectorWithScalarsContext, DataConnectorsWithScalars, ScalarTypeWithRepresentationInfo,
|
||||
@ -19,15 +19,15 @@ use crate::stages::{data_connectors, scalar_types};
|
||||
|
||||
pub struct DataConnectorWithScalarsOutput<'a> {
|
||||
pub data_connectors: DataConnectorsWithScalars<'a>,
|
||||
pub graphql_types: HashSet<ast::TypeName>,
|
||||
pub graphql_types: BTreeSet<ast::TypeName>,
|
||||
}
|
||||
|
||||
/// resolve data connector scalar representations
|
||||
pub fn resolve<'a>(
|
||||
metadata_accessor: &'a open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &'a data_connectors::DataConnectors,
|
||||
scalar_types: &'a HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
existing_graphql_types: &'a HashSet<ast::TypeName>,
|
||||
scalar_types: &'a BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
existing_graphql_types: &'a BTreeSet<ast::TypeName>,
|
||||
) -> Result<DataConnectorWithScalarsOutput<'a>, Error> {
|
||||
let mut graphql_types = existing_graphql_types.clone();
|
||||
|
||||
@ -119,13 +119,13 @@ pub fn resolve<'a>(
|
||||
// convert from types in previous stage to this stage
|
||||
fn convert_data_connectors_contexts<'a>(
|
||||
data_connectors: &data_connectors::DataConnectors<'a>,
|
||||
) -> HashMap<Qualified<DataConnectorName>, DataConnectorWithScalarsContext<'a>> {
|
||||
let mut data_connectors_with_scalars = HashMap::new();
|
||||
) -> BTreeMap<Qualified<DataConnectorName>, DataConnectorWithScalarsContext<'a>> {
|
||||
let mut data_connectors_with_scalars = BTreeMap::new();
|
||||
|
||||
for (data_connector_name, data_connectors::DataConnectorContext { scalars, inner }) in
|
||||
&data_connectors.data_connectors
|
||||
{
|
||||
let mut new_scalars = HashMap::new();
|
||||
let mut new_scalars = BTreeMap::new();
|
||||
for (scalar_name, scalar) in scalars {
|
||||
new_scalars.insert(
|
||||
*scalar_name,
|
||||
@ -151,7 +151,7 @@ fn convert_data_connectors_contexts<'a>(
|
||||
// helper function to determine whether a ndc type is a simple scalar
|
||||
pub fn get_simple_scalar<'a, 'b>(
|
||||
t: ndc_models::Type,
|
||||
scalars: &'a HashMap<&str, ScalarTypeWithRepresentationInfo<'b>>,
|
||||
scalars: &'a BTreeMap<&str, ScalarTypeWithRepresentationInfo<'b>>,
|
||||
) -> Option<(String, &'a ScalarTypeWithRepresentationInfo<'b>)> {
|
||||
match t {
|
||||
ndc_models::Type::Named { name } => scalars.get(name.as_str()).map(|info| (name, info)),
|
||||
|
@ -6,13 +6,13 @@ use lang_graphql::ast::common as ast;
|
||||
use ndc_models;
|
||||
use open_dds::data_connector::DataConnectorName;
|
||||
use open_dds::types::TypeName;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// information about a data connector
|
||||
/// currently this contains partial ScalarTypeInfo, which we add to later
|
||||
pub struct DataConnectorWithScalarsContext<'a> {
|
||||
pub inner: data_connectors::DataConnectorCoreInfo<'a>,
|
||||
pub scalars: HashMap<&'a str, ScalarTypeWithRepresentationInfo<'a>>,
|
||||
pub scalars: BTreeMap<&'a str, ScalarTypeWithRepresentationInfo<'a>>,
|
||||
}
|
||||
|
||||
// basic scalar type info
|
||||
@ -25,5 +25,5 @@ pub struct ScalarTypeWithRepresentationInfo<'a> {
|
||||
|
||||
pub struct DataConnectorsWithScalars<'a> {
|
||||
pub data_connectors_with_scalars:
|
||||
HashMap<Qualified<DataConnectorName>, DataConnectorWithScalarsContext<'a>>,
|
||||
BTreeMap<Qualified<DataConnectorName>, DataConnectorWithScalarsContext<'a>>,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::types::error::Error;
|
||||
use crate::types::subgraph::Qualified;
|
||||
|
||||
pub mod types;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
pub use types::{
|
||||
ComparisonOperators, DataConnectorContext, DataConnectorCoreInfo, DataConnectorLink,
|
||||
DataConnectors,
|
||||
@ -12,7 +12,7 @@ pub use types::{
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
) -> Result<types::DataConnectors, Error> {
|
||||
let mut data_connectors = HashMap::new();
|
||||
let mut data_connectors = BTreeMap::new();
|
||||
for open_dds::accessor::QualifiedObject {
|
||||
subgraph,
|
||||
object: data_connector,
|
||||
|
@ -18,7 +18,7 @@ use serde::{
|
||||
de::Error as DeError,
|
||||
ser::{Error as SerError, SerializeMap},
|
||||
};
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
use std::{collections::BTreeMap, str::FromStr};
|
||||
|
||||
/// information that does not change between resolver stages
|
||||
#[derive(Clone, Copy)]
|
||||
@ -33,7 +33,7 @@ pub struct DataConnectorCoreInfo<'a> {
|
||||
/// currently this contains partial ScalarTypeInfo, which we add to later
|
||||
pub struct DataConnectorContext<'a> {
|
||||
pub inner: DataConnectorCoreInfo<'a>,
|
||||
pub scalars: HashMap<&'a str, ScalarTypeInfo<'a>>,
|
||||
pub scalars: BTreeMap<&'a str, ScalarTypeInfo<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> DataConnectorContext<'a> {
|
||||
@ -95,7 +95,7 @@ impl<'a> ScalarTypeInfo<'a> {
|
||||
}
|
||||
|
||||
pub struct DataConnectors<'a> {
|
||||
pub data_connectors: HashMap<Qualified<DataConnectorName>, DataConnectorContext<'a>>,
|
||||
pub data_connectors: BTreeMap<Qualified<DataConnectorName>, DataConnectorContext<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -265,7 +265,7 @@ impl<'de> Deserialize<'de> for SerializableHeaderMap {
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let hash_map = HashMap::<String, String>::deserialize(deserializer)?;
|
||||
let hash_map = BTreeMap::<String, String>::deserialize(deserializer)?;
|
||||
let header_map: HeaderMap = hash_map
|
||||
.into_iter()
|
||||
.map(|(k, v)| {
|
||||
|
@ -7,7 +7,7 @@ use crate::stages::{
|
||||
use crate::types::permission::ValueExpression;
|
||||
use indexmap::IndexMap;
|
||||
use open_dds::{models::ModelName, types::CustomTypeName};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
pub use types::{
|
||||
FilterPermission, ModelPredicate, ModelTargetSource, ModelWithPermissions,
|
||||
PredicateRelationshipInfo, SelectPermission,
|
||||
@ -33,10 +33,10 @@ use open_dds::{
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
models: &IndexMap<Qualified<ModelName>, models::Model>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -48,7 +48,7 @@ pub fn resolve(
|
||||
model_name.clone(),
|
||||
ModelWithPermissions {
|
||||
model: model.clone(),
|
||||
select_permissions: HashMap::new(),
|
||||
select_permissions: BTreeMap::new(),
|
||||
},
|
||||
)
|
||||
})
|
||||
@ -95,7 +95,7 @@ pub fn resolve(
|
||||
pub(crate) fn resolve_ndc_type(
|
||||
data_connector: &Qualified<DataConnectorName>,
|
||||
source_type: &ndc_models::Type,
|
||||
scalars: &HashMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
scalars: &BTreeMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
subgraph: &str,
|
||||
) -> Result<QualifiedTypeReference, Error> {
|
||||
match source_type {
|
||||
@ -147,7 +147,7 @@ fn resolve_model_predicate(
|
||||
subgraph: &str,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
fields: &IndexMap<FieldName, object_types::FieldDefinition>,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
models: &IndexMap<Qualified<ModelName>, models::Model>,
|
||||
) -> Result<ModelPredicate, Error> {
|
||||
match model_predicate {
|
||||
@ -437,7 +437,7 @@ fn resolve_binary_operator_for_model(
|
||||
data_connector: &Qualified<DataConnectorName>,
|
||||
field_name: &FieldName,
|
||||
fields: &IndexMap<FieldName, object_types::FieldDefinition>,
|
||||
scalars: &HashMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
scalars: &BTreeMap<&str, data_connector_scalar_types::ScalarTypeWithRepresentationInfo>,
|
||||
ndc_scalar_type: &ndc_models::ScalarType,
|
||||
subgraph: &str,
|
||||
) -> Result<(String, QualifiedTypeReference), Error> {
|
||||
@ -479,7 +479,7 @@ fn resolve_binary_operator_for_model(
|
||||
/// `data_type`, it will throw an error if the type is not found to be an object
|
||||
/// or if the model has an unknown data type.
|
||||
fn get_model_object_type_representation<'s>(
|
||||
object_types: &'s HashMap<
|
||||
object_types: &'s BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
relationships::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -500,15 +500,15 @@ pub fn resolve_model_select_permissions(
|
||||
subgraph: &str,
|
||||
model_permissions: &ModelPermissionsV1,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
models: &IndexMap<Qualified<ModelName>, models::Model>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
) -> Result<HashMap<Role, SelectPermission>, Error> {
|
||||
let mut validated_permissions = HashMap::new();
|
||||
) -> Result<BTreeMap<Role, SelectPermission>, Error> {
|
||||
let mut validated_permissions = BTreeMap::new();
|
||||
for model_permission in &model_permissions.permissions {
|
||||
if let Some(select) = &model_permission.select {
|
||||
let resolved_predicate = match &select.filter {
|
||||
|
@ -8,7 +8,7 @@ use open_dds::{
|
||||
types::CustomTypeName,
|
||||
};
|
||||
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::types::subgraph::{Qualified, QualifiedTypeReference};
|
||||
|
||||
@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
pub struct ModelWithPermissions {
|
||||
pub model: models::Model,
|
||||
pub select_permissions: HashMap<Role, SelectPermission>,
|
||||
pub select_permissions: BTreeMap<Role, SelectPermission>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -31,22 +31,22 @@ use open_dds::{
|
||||
types::{CustomTypeName, FieldName},
|
||||
};
|
||||
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::iter;
|
||||
|
||||
/// resolve models
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
existing_graphql_types: &HashSet<ast::TypeName>,
|
||||
global_id_enabled_types: &HashMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
apollo_federation_entity_enabled_types: &HashMap<
|
||||
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
||||
global_id_enabled_types: &BTreeMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
apollo_federation_entity_enabled_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
Option<Qualified<open_dds::models::ModelName>>,
|
||||
>,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -55,7 +55,7 @@ pub fn resolve(
|
||||
// resolve models
|
||||
// TODO: validate types
|
||||
let mut models = IndexMap::new();
|
||||
let mut global_id_models = HashMap::new();
|
||||
let mut global_id_models = BTreeMap::new();
|
||||
let mut graphql_types = existing_graphql_types.clone();
|
||||
let mut global_id_enabled_types = global_id_enabled_types.clone();
|
||||
let mut apollo_federation_entity_enabled_types = apollo_federation_entity_enabled_types.clone();
|
||||
@ -132,7 +132,7 @@ fn resolve_filter_expression_type(
|
||||
model: &ModelV1,
|
||||
model_data_type: &Qualified<CustomTypeName>,
|
||||
subgraph: &str,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -213,13 +213,13 @@ fn resolve_orderable_fields(
|
||||
fn resolve_model(
|
||||
subgraph: &str,
|
||||
model: &ModelV1,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
global_id_enabled_types: &mut HashMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
apollo_federation_entity_enabled_types: &mut HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
global_id_enabled_types: &mut BTreeMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
apollo_federation_entity_enabled_types: &mut BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
Option<Qualified<ModelName>>,
|
||||
>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -251,7 +251,7 @@ fn resolve_model(
|
||||
model_name: qualified_model_name,
|
||||
});
|
||||
}
|
||||
// model has `global_id_source`; insert into the hashmap of `global_id_enabled_types`
|
||||
// model has `global_id_source`; insert into the BTreeMap of `global_id_enabled_types`
|
||||
match global_id_enabled_types.get_mut(&qualified_object_type_name) {
|
||||
None => {
|
||||
// this shouldn't happen; but for some reason the object type
|
||||
@ -266,7 +266,7 @@ fn resolve_model(
|
||||
}
|
||||
}
|
||||
global_id_source = Some(NDCFieldSourceMapping {
|
||||
ndc_mapping: HashMap::new(),
|
||||
ndc_mapping: BTreeMap::new(),
|
||||
});
|
||||
};
|
||||
let mut apollo_federation_key_source = None;
|
||||
@ -288,7 +288,7 @@ fn resolve_model(
|
||||
model_name: qualified_model_name,
|
||||
});
|
||||
}
|
||||
// model has `apollo_federation_entity_source`; insert into the hashmap of
|
||||
// model has `apollo_federation_entity_source`; insert into the BTreeMap of
|
||||
// `apollo_federation_entity_enabled_types`
|
||||
match apollo_federation_entity_enabled_types.get_mut(&qualified_object_type_name) {
|
||||
None => {
|
||||
@ -314,7 +314,7 @@ fn resolve_model(
|
||||
}
|
||||
}
|
||||
apollo_federation_key_source = Some(NDCFieldSourceMapping {
|
||||
ndc_mapping: HashMap::new(),
|
||||
ndc_mapping: BTreeMap::new(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -369,7 +369,7 @@ fn resolve_model(
|
||||
fn resolve_model_graphql_api(
|
||||
model_graphql_definition: &ModelGraphQlDefinition,
|
||||
model: &mut Model,
|
||||
existing_graphql_types: &mut HashSet<ast::TypeName>,
|
||||
existing_graphql_types: &mut BTreeSet<ast::TypeName>,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
model_description: &Option<String>,
|
||||
graphql_config: &graphql_config::GraphqlConfig,
|
||||
@ -463,7 +463,7 @@ fn resolve_model_graphql_api(
|
||||
data_connector: model_source.data_connector.name.clone(),
|
||||
})?;
|
||||
|
||||
let mut order_by_fields = HashMap::new();
|
||||
let mut order_by_fields = BTreeMap::new();
|
||||
for (field_name, field_mapping) in field_mappings.iter() {
|
||||
order_by_fields.insert(
|
||||
field_name.clone(),
|
||||
@ -570,9 +570,9 @@ fn resolve_model_source(
|
||||
model: &mut Model,
|
||||
subgraph: &str,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &HashMap<
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, type_permissions::ObjectTypeWithPermissions>,
|
||||
scalar_types: &BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
object_boolean_expression_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
boolean_expressions::ObjectBooleanExpressionType,
|
||||
>,
|
||||
@ -734,7 +734,7 @@ fn resolve_model_source(
|
||||
/// `data_type`, it will throw an error if the type is not found to be an object
|
||||
/// or if the model has an unknown data type.
|
||||
fn get_model_object_type_representation<'s>(
|
||||
object_types: &'s HashMap<
|
||||
object_types: &'s BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
type_permissions::ObjectTypeWithPermissions,
|
||||
>,
|
||||
|
@ -16,7 +16,7 @@ use open_dds::{
|
||||
types::{CustomTypeName, FieldName},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
#[derive(
|
||||
Serialize,
|
||||
@ -37,10 +37,10 @@ pub struct ConnectorArgumentName(pub String);
|
||||
|
||||
pub struct ModelsOutput {
|
||||
pub models: IndexMap<Qualified<ModelName>, Model>,
|
||||
pub graphql_types: HashSet<ast::TypeName>,
|
||||
pub global_id_enabled_types: HashMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
pub graphql_types: BTreeSet<ast::TypeName>,
|
||||
pub global_id_enabled_types: BTreeMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
pub apollo_federation_entity_enabled_types:
|
||||
HashMap<Qualified<CustomTypeName>, Option<Qualified<open_dds::models::ModelName>>>,
|
||||
BTreeMap<Qualified<CustomTypeName>, Option<Qualified<open_dds::models::ModelName>>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -74,7 +74,7 @@ pub struct OrderByExpressionInfo {
|
||||
pub struct ModelOrderByExpression {
|
||||
pub data_connector_name: Qualified<DataConnectorName>,
|
||||
pub order_by_type_name: ast::TypeName,
|
||||
pub order_by_fields: HashMap<FieldName, OrderByExpressionInfo>,
|
||||
pub order_by_fields: BTreeMap<FieldName, OrderByExpressionInfo>,
|
||||
pub order_by_field_name: ast::Name,
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ pub struct ModelSource {
|
||||
deserialize_with = "deserialize_qualified_btreemap"
|
||||
)]
|
||||
pub type_mappings: BTreeMap<Qualified<CustomTypeName>, object_types::TypeMapping>,
|
||||
pub argument_mappings: HashMap<ArgumentName, ConnectorArgumentName>,
|
||||
pub argument_mappings: BTreeMap<ArgumentName, ConnectorArgumentName>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -131,5 +131,5 @@ pub struct Model {
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct NDCFieldSourceMapping {
|
||||
pub ndc_mapping: HashMap<FieldName, NdcColumnForComparison>,
|
||||
pub ndc_mapping: BTreeMap<FieldName, NdcColumnForComparison>,
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
pub mod types;
|
||||
use open_dds::types::CustomTypeName;
|
||||
pub use types::{
|
||||
@ -22,10 +22,10 @@ pub(crate) fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &data_connectors::DataConnectors,
|
||||
) -> Result<DataConnectorTypeMappingsOutput, Error> {
|
||||
let mut object_types = HashMap::new();
|
||||
let mut graphql_types = HashSet::new();
|
||||
let mut global_id_enabled_types = HashMap::new();
|
||||
let mut apollo_federation_entity_enabled_types = HashMap::new();
|
||||
let mut object_types = BTreeMap::new();
|
||||
let mut graphql_types = BTreeSet::new();
|
||||
let mut global_id_enabled_types = BTreeMap::new();
|
||||
let mut apollo_federation_entity_enabled_types = BTreeMap::new();
|
||||
|
||||
for open_dds::accessor::QualifiedObject {
|
||||
subgraph,
|
||||
@ -111,14 +111,14 @@ fn resolve_field(
|
||||
|
||||
pub fn resolve_object_type(
|
||||
object_type_definition: &open_dds::types::ObjectTypeV1,
|
||||
existing_graphql_types: &mut HashSet<ast::TypeName>,
|
||||
existing_graphql_types: &mut BTreeSet<ast::TypeName>,
|
||||
qualified_type_name: &Qualified<CustomTypeName>,
|
||||
subgraph: &str,
|
||||
global_id_enabled_types: &mut HashMap<
|
||||
global_id_enabled_types: &mut BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
Vec<Qualified<open_dds::models::ModelName>>,
|
||||
>,
|
||||
apollo_federation_entity_enabled_types: &mut HashMap<
|
||||
apollo_federation_entity_enabled_types: &mut BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
Option<Qualified<open_dds::models::ModelName>>,
|
||||
>,
|
||||
@ -282,7 +282,7 @@ pub fn resolve_data_connector_type_mapping(
|
||||
.field_mapping
|
||||
.0
|
||||
.iter()
|
||||
.collect::<HashMap<_, _>>();
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
let mut resolved_field_mappings = BTreeMap::new();
|
||||
for field_name in type_representation.fields.keys() {
|
||||
let resolved_field_mapping_column: &str =
|
||||
|
@ -4,7 +4,7 @@ use indexmap::IndexMap;
|
||||
|
||||
use open_dds::types::{CustomTypeName, Deprecated, FieldName};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use open_dds::models::ModelName;
|
||||
|
||||
@ -16,7 +16,7 @@ use open_dds::data_connector::{DataConnectorName, DataConnectorObjectType};
|
||||
/// A mapping from a data connector to their objects, which contain field types.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
pub struct DataConnectorTypeMappingsForObject(
|
||||
HashMap<Qualified<DataConnectorName>, HashMap<DataConnectorObjectType, TypeMapping>>,
|
||||
BTreeMap<Qualified<DataConnectorName>, BTreeMap<DataConnectorObjectType, TypeMapping>>,
|
||||
);
|
||||
|
||||
impl Default for DataConnectorTypeMappingsForObject {
|
||||
@ -27,7 +27,7 @@ impl Default for DataConnectorTypeMappingsForObject {
|
||||
|
||||
impl DataConnectorTypeMappingsForObject {
|
||||
pub fn new() -> Self {
|
||||
Self(HashMap::new())
|
||||
Self(BTreeMap::new())
|
||||
}
|
||||
|
||||
pub fn get(
|
||||
@ -76,11 +76,11 @@ impl DataConnectorTypeMappingsForObject {
|
||||
|
||||
/// output of `object_types` step
|
||||
pub struct DataConnectorTypeMappingsOutput {
|
||||
pub graphql_types: HashSet<ast::TypeName>,
|
||||
pub global_id_enabled_types: HashMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
pub graphql_types: BTreeSet<ast::TypeName>,
|
||||
pub global_id_enabled_types: BTreeMap<Qualified<CustomTypeName>, Vec<Qualified<ModelName>>>,
|
||||
pub apollo_federation_entity_enabled_types:
|
||||
HashMap<Qualified<CustomTypeName>, Option<Qualified<open_dds::models::ModelName>>>,
|
||||
pub object_types: HashMap<Qualified<CustomTypeName>, ObjectTypeWithTypeMappings>,
|
||||
BTreeMap<Qualified<CustomTypeName>, Option<Qualified<open_dds::models::ModelName>>>,
|
||||
pub object_types: BTreeMap<Qualified<CustomTypeName>, ObjectTypeWithTypeMappings>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -5,7 +5,7 @@ pub use types::{
|
||||
RelationshipTarget, RelationshipTargetName,
|
||||
};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
@ -21,21 +21,21 @@ use crate::stages::{
|
||||
|
||||
use open_dds::relationships::{self, FieldAccess, RelationshipName, RelationshipV1};
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
/// resolve relationships
|
||||
/// returns updated `types` value
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
object_types_with_permissions: &HashMap<
|
||||
object_types_with_permissions: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
type_permissions::ObjectTypeWithPermissions,
|
||||
>,
|
||||
models: &IndexMap<Qualified<ModelName>, models::Model>,
|
||||
commands: &IndexMap<Qualified<CommandName>, commands::Command>,
|
||||
) -> Result<HashMap<Qualified<CustomTypeName>, ObjectTypeWithRelationships>, Error> {
|
||||
let mut object_types_with_relationships = HashMap::new();
|
||||
) -> Result<BTreeMap<Qualified<CustomTypeName>, ObjectTypeWithRelationships>, Error> {
|
||||
let mut object_types_with_relationships = BTreeMap::new();
|
||||
for (
|
||||
object_type_name,
|
||||
type_permissions::ObjectTypeWithPermissions {
|
||||
@ -164,7 +164,7 @@ fn resolve_relationship_mappings_model(
|
||||
data_connectors: &data_connector_scalar_types::DataConnectorsWithScalars,
|
||||
) -> Result<Vec<RelationshipModelMapping>, Error> {
|
||||
let mut resolved_relationship_mappings = Vec::new();
|
||||
let mut field_mapping_hashset_for_validation: HashSet<&String> = HashSet::new();
|
||||
let mut field_mapping_btree_set_for_validation: BTreeSet<&String> = BTreeSet::new();
|
||||
for relationship_mapping in &relationship.mapping {
|
||||
let resolved_relationship_source_mapping = resolve_relationship_source_mapping(
|
||||
&relationship.name,
|
||||
@ -217,7 +217,7 @@ fn resolve_relationship_mappings_model(
|
||||
|
||||
// Check if the source field is already mapped to a target field
|
||||
let resolved_relationship_mapping = {
|
||||
if field_mapping_hashset_for_validation
|
||||
if field_mapping_btree_set_for_validation
|
||||
.insert(&resolved_relationship_source_mapping.field_name.0)
|
||||
{
|
||||
let target_ndc_column = target_model
|
||||
@ -267,8 +267,8 @@ fn resolve_relationship_mappings_command(
|
||||
target_command: &commands::Command,
|
||||
) -> Result<Vec<RelationshipCommandMapping>, Error> {
|
||||
let mut resolved_relationship_mappings = Vec::new();
|
||||
let mut field_mapping_hashset_for_validation: HashSet<&String> = HashSet::new();
|
||||
let mut target_command_arguments_hashset_for_validation: HashSet<&String> = HashSet::new();
|
||||
let mut field_mapping_btree_set_for_validation: BTreeSet<&String> = BTreeSet::new();
|
||||
let mut target_command_arguments_btree_set_for_validation: BTreeSet<&String> = BTreeSet::new();
|
||||
|
||||
for relationship_mapping in &relationship.mapping {
|
||||
let resolved_relationship_source_mapping = resolve_relationship_source_mapping(
|
||||
@ -302,7 +302,7 @@ fn resolve_relationship_mappings_command(
|
||||
}
|
||||
|
||||
// Check if the target argument is already mapped to a field in the source type.
|
||||
if !target_command_arguments_hashset_for_validation.insert(&target_argument_name.0) {
|
||||
if !target_command_arguments_btree_set_for_validation.insert(&target_argument_name.0) {
|
||||
return Err(Error::RelationshipError {
|
||||
relationship_error: RelationshipError::ArgumentMappingExistsInRelationship {
|
||||
argument_name: target_argument_name.clone(),
|
||||
@ -315,7 +315,7 @@ fn resolve_relationship_mappings_command(
|
||||
|
||||
// Check if the source field is already mapped to a target argument
|
||||
let resolved_relationship_mapping = {
|
||||
if field_mapping_hashset_for_validation
|
||||
if field_mapping_btree_set_for_validation
|
||||
.insert(&resolved_relationship_source_mapping.field_name.0)
|
||||
{
|
||||
Ok(RelationshipCommandMapping {
|
||||
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::helpers::types::NdcColumnForComparison;
|
||||
use lang_graphql::ast::common as ast;
|
||||
use open_dds::arguments::ArgumentName;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use open_dds::relationships::{FieldAccess, RelationshipName, RelationshipType};
|
||||
use open_dds::types::Deprecated;
|
||||
@ -18,10 +18,10 @@ pub struct ObjectTypeWithRelationships {
|
||||
pub object_type: object_types::ObjectTypeRepresentation,
|
||||
/// permissions on this type, when it is used in an output context (e.g. as
|
||||
/// a return type of Model or Command)
|
||||
pub type_output_permissions: HashMap<Role, open_dds::permissions::TypeOutputPermission>,
|
||||
pub type_output_permissions: BTreeMap<Role, open_dds::permissions::TypeOutputPermission>,
|
||||
/// permissions on this type, when it is used in an input context (e.g. in
|
||||
/// an argument type of Model or Command)
|
||||
pub type_input_permissions: HashMap<Role, type_permissions::TypeInputPermission>,
|
||||
pub type_input_permissions: BTreeMap<Role, type_permissions::TypeInputPermission>,
|
||||
/// any relationships defined on this object
|
||||
pub relationships: IndexMap<ast::Name, Relationship>,
|
||||
/// type mappings for each data connector
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use hasura_authn_core::Role;
|
||||
use indexmap::IndexMap;
|
||||
@ -11,7 +11,7 @@ use crate::stages::{command_permissions, model_permissions, relationships};
|
||||
|
||||
/// Gather all roles from various permission objects.
|
||||
pub fn resolve(
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
models: &IndexMap<Qualified<ModelName>, model_permissions::ModelWithPermissions>,
|
||||
commands: &IndexMap<Qualified<CommandName>, command_permissions::CommandWithPermissions>,
|
||||
) -> Vec<Role> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use lang_graphql::ast::common as ast;
|
||||
|
||||
@ -12,9 +12,9 @@ pub use types::{ScalarTypeRepresentation, ScalarTypesOutput};
|
||||
/// resolve scalar types
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
existing_graphql_types: &HashSet<ast::TypeName>,
|
||||
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
||||
) -> Result<ScalarTypesOutput, Error> {
|
||||
let mut scalar_types = HashMap::new();
|
||||
let mut scalar_types = BTreeMap::new();
|
||||
let mut graphql_types = existing_graphql_types.clone();
|
||||
|
||||
for open_dds::accessor::QualifiedObject {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::types::subgraph::Qualified;
|
||||
use lang_graphql::ast::common as ast;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use open_dds::types::CustomTypeName;
|
||||
|
||||
@ -12,6 +12,6 @@ pub struct ScalarTypeRepresentation {
|
||||
}
|
||||
|
||||
pub struct ScalarTypesOutput {
|
||||
pub scalar_types: HashMap<Qualified<CustomTypeName>, ScalarTypeRepresentation>,
|
||||
pub graphql_types: HashSet<ast::TypeName>,
|
||||
pub scalar_types: BTreeMap<Qualified<CustomTypeName>, ScalarTypeRepresentation>,
|
||||
pub graphql_types: BTreeSet<ast::TypeName>,
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use open_dds::permissions::{
|
||||
FieldPreset, Role, TypeOutputPermission, TypePermissionsV1, ValueExpression,
|
||||
@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct TypeInputPermission {
|
||||
pub field_presets: HashMap<FieldName, ValueExpression>,
|
||||
pub field_presets: BTreeMap<FieldName, ValueExpression>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -24,10 +24,10 @@ pub struct ObjectTypeWithPermissions {
|
||||
pub object_type: object_types::ObjectTypeRepresentation,
|
||||
/// permissions on this type, when it is used in an output context (e.g. as
|
||||
/// a return type of Model or Command)
|
||||
pub type_output_permissions: HashMap<Role, TypeOutputPermission>,
|
||||
pub type_output_permissions: BTreeMap<Role, TypeOutputPermission>,
|
||||
/// permissions on this type, when it is used in an input context (e.g. in
|
||||
/// an argument type of Model or Command)
|
||||
pub type_input_permissions: HashMap<Role, TypeInputPermission>,
|
||||
pub type_input_permissions: BTreeMap<Role, TypeInputPermission>,
|
||||
/// type mappings for each data connector
|
||||
pub type_mappings: object_types::DataConnectorTypeMappingsForObject,
|
||||
}
|
||||
@ -35,17 +35,17 @@ pub struct ObjectTypeWithPermissions {
|
||||
/// resolve type permissions
|
||||
pub fn resolve(
|
||||
metadata_accessor: &open_dds::accessor::MetadataAccessor,
|
||||
object_types: &HashMap<Qualified<CustomTypeName>, object_types::ObjectTypeWithTypeMappings>,
|
||||
) -> Result<HashMap<Qualified<CustomTypeName>, ObjectTypeWithPermissions>, Error> {
|
||||
let mut object_types_with_permissions = HashMap::new();
|
||||
object_types: &BTreeMap<Qualified<CustomTypeName>, object_types::ObjectTypeWithTypeMappings>,
|
||||
) -> Result<BTreeMap<Qualified<CustomTypeName>, ObjectTypeWithPermissions>, Error> {
|
||||
let mut object_types_with_permissions = BTreeMap::new();
|
||||
for (object_type_name, object_type) in object_types {
|
||||
object_types_with_permissions.insert(
|
||||
object_type_name.clone(),
|
||||
ObjectTypeWithPermissions {
|
||||
object_type: object_type.object_type.clone(),
|
||||
type_mappings: object_type.type_mappings.clone(),
|
||||
type_input_permissions: HashMap::new(),
|
||||
type_output_permissions: HashMap::new(),
|
||||
type_input_permissions: BTreeMap::new(),
|
||||
type_output_permissions: BTreeMap::new(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -84,8 +84,8 @@ pub fn resolve(
|
||||
pub fn resolve_output_type_permission(
|
||||
object_type_representation: &object_types::ObjectTypeRepresentation,
|
||||
type_permissions: &TypePermissionsV1,
|
||||
) -> Result<HashMap<Role, TypeOutputPermission>, Error> {
|
||||
let mut resolved_type_permissions = HashMap::new();
|
||||
) -> Result<BTreeMap<Role, TypeOutputPermission>, Error> {
|
||||
let mut resolved_type_permissions = BTreeMap::new();
|
||||
|
||||
// validate all the fields definied in output permissions actually
|
||||
// exist in this type definition
|
||||
@ -115,12 +115,12 @@ pub fn resolve_output_type_permission(
|
||||
pub(crate) fn resolve_input_type_permission(
|
||||
object_type_representation: &object_types::ObjectTypeRepresentation,
|
||||
type_permissions: &TypePermissionsV1,
|
||||
) -> Result<HashMap<Role, TypeInputPermission>, Error> {
|
||||
let mut resolved_type_permissions = HashMap::new();
|
||||
) -> Result<BTreeMap<Role, TypeInputPermission>, Error> {
|
||||
let mut resolved_type_permissions = BTreeMap::new();
|
||||
|
||||
for type_permission in &type_permissions.permissions {
|
||||
if let Some(input) = &type_permission.input {
|
||||
let mut resolved_field_presets = HashMap::new();
|
||||
let mut resolved_field_presets = BTreeMap::new();
|
||||
for FieldPreset {
|
||||
field: field_name,
|
||||
value,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use hasura_authn_core::Role;
|
||||
use indexmap::IndexMap;
|
||||
@ -17,12 +17,12 @@ use crate::stages::{
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
pub struct Metadata {
|
||||
pub object_types:
|
||||
HashMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
pub scalar_types: HashMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
BTreeMap<Qualified<CustomTypeName>, relationships::ObjectTypeWithRelationships>,
|
||||
pub scalar_types: BTreeMap<Qualified<CustomTypeName>, scalar_types::ScalarTypeRepresentation>,
|
||||
pub models: IndexMap<Qualified<ModelName>, model_permissions::ModelWithPermissions>,
|
||||
pub commands: IndexMap<Qualified<CommandName>, command_permissions::CommandWithPermissions>,
|
||||
pub object_boolean_expression_types:
|
||||
HashMap<Qualified<CustomTypeName>, boolean_expressions::ObjectBooleanExpressionType>,
|
||||
BTreeMap<Qualified<CustomTypeName>, boolean_expressions::ObjectBooleanExpressionType>,
|
||||
pub graphql_config: graphql_config::GlobalGraphqlConfig,
|
||||
pub roles: Vec<Role>,
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, ops::Deref};
|
||||
use std::{collections::BTreeMap, ops::Deref};
|
||||
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -125,10 +125,10 @@ pub struct CommandV1 {
|
||||
/// is the argument name used in the data connector.
|
||||
// We wrap maps into newtype structs so that we have a type and title for them in the JSONSchema which
|
||||
// makes it easier to auto-generate documentation.
|
||||
pub struct ArgumentMapping(pub HashMap<ArgumentName, String>);
|
||||
pub struct ArgumentMapping(pub BTreeMap<ArgumentName, String>);
|
||||
|
||||
impl Deref for ArgumentMapping {
|
||||
type Target = HashMap<ArgumentName, String>;
|
||||
type Target = BTreeMap<ArgumentName, String>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
|
@ -16,6 +16,8 @@ use crate::{identifier::Identifier, impl_OpenDd_default_for};
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Hash,
|
||||
JsonSchema,
|
||||
derive_more::Display,
|
||||
|
@ -20,6 +20,8 @@ use crate::{
|
||||
Debug,
|
||||
Eq,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
JsonSchema,
|
||||
Hash,
|
||||
derive_more::Display,
|
||||
|
@ -13,7 +13,7 @@ use super::types::ArgumentNameAndPath;
|
||||
/// Build namespace annotation for select permissions
|
||||
pub(crate) fn get_select_permissions_namespace_annotations(
|
||||
model: &metadata_resolve::ModelWithPermissions,
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -97,7 +97,7 @@ pub(crate) fn get_select_one_namespace_annotations(
|
||||
model: &metadata_resolve::ModelWithPermissions,
|
||||
object_type_representation: &metadata_resolve::ObjectTypeWithRelationships,
|
||||
select_unique: &metadata_resolve::SelectUniqueGraphQlDefinition,
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -124,7 +124,7 @@ pub(crate) fn get_model_relationship_namespace_annotations(
|
||||
source_object_type_representation: &metadata_resolve::ObjectTypeWithRelationships,
|
||||
target_object_type_representation: &metadata_resolve::ObjectTypeWithRelationships,
|
||||
mappings: &[metadata_resolve::RelationshipModelMapping],
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -151,7 +151,7 @@ pub(crate) fn get_model_relationship_namespace_annotations(
|
||||
/// Build namespace annotation for commands
|
||||
pub(crate) fn get_command_namespace_annotations(
|
||||
command: &metadata_resolve::CommandWithPermissions,
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -227,7 +227,7 @@ fn build_annotations_from_input_object_type_permissions(
|
||||
field_path: &mut [String],
|
||||
type_reference: &QualifiedTypeReference,
|
||||
ndc_argument_name: &Option<ConnectorArgumentName>,
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
@ -361,7 +361,7 @@ pub(crate) fn get_command_relationship_namespace_annotations(
|
||||
command: &metadata_resolve::CommandWithPermissions,
|
||||
source_object_type_representation: &metadata_resolve::ObjectTypeWithRelationships,
|
||||
mappings: &[metadata_resolve::RelationshipCommandMapping],
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
|
@ -56,7 +56,7 @@ pub struct NodeFieldTypeNameMapping {
|
||||
// `model_source` is are optional because we allow building schema without specifying a data source
|
||||
// In such a case, `global_id_fields_ndc_mapping` will also be empty
|
||||
pub model_source: Option<metadata_resolve::ModelSource>,
|
||||
pub global_id_fields_ndc_mapping: HashMap<types::FieldName, NdcColumnForComparison>,
|
||||
pub global_id_fields_ndc_mapping: BTreeMap<types::FieldName, NdcColumnForComparison>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -65,7 +65,7 @@ pub struct EntityFieldTypeNameMapping {
|
||||
// `model_source` is are optional because we allow building schema without specifying a data source
|
||||
// In such a case, `global_id_fields_ndc_mapping` will also be empty
|
||||
pub model_source: Option<metadata_resolve::ModelSource>,
|
||||
pub key_fields_ndc_mapping: HashMap<types::FieldName, NdcColumnForComparison>,
|
||||
pub key_fields_ndc_mapping: BTreeMap<types::FieldName, NdcColumnForComparison>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@ -98,7 +98,7 @@ pub struct CommandSourceDetail {
|
||||
deserialize_with = "deserialize_qualified_btreemap"
|
||||
)]
|
||||
pub type_mappings: BTreeMap<Qualified<types::CustomTypeName>, TypeMapping>,
|
||||
pub argument_mappings: HashMap<ArgumentName, ConnectorArgumentName>,
|
||||
pub argument_mappings: BTreeMap<ArgumentName, ConnectorArgumentName>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Display)]
|
||||
|
@ -179,7 +179,7 @@ fn object_type_fields(
|
||||
builder: &mut gql_schema::Builder<GDS>,
|
||||
type_name: &Qualified<CustomTypeName>,
|
||||
object_type_representation: &metadata_resolve::ObjectTypeWithRelationships,
|
||||
object_types: &HashMap<
|
||||
object_types: &BTreeMap<
|
||||
Qualified<CustomTypeName>,
|
||||
metadata_resolve::ObjectTypeWithRelationships,
|
||||
>,
|
||||
|
Loading…
Reference in New Issue
Block a user