Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apollo-federation/src/link/cost_spec_definition.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use apollo_compiler::ast::Argument;
use apollo_compiler::ast::Directive;
use apollo_compiler::collections::IndexMap;
use apollo_compiler::collections::HashMap;
use apollo_compiler::name;
use apollo_compiler::schema::Component;
use apollo_compiler::schema::EnumType;
Expand Down Expand Up @@ -40,7 +40,7 @@ macro_rules! propagate_demand_control_directives {
subgraph_schema: &FederationSchema,
source: &$directives_ty,
dest: &mut $directives_ty,
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let cost_directive_name = original_directive_names.get(&COST_DIRECTIVE_NAME_IN_SPEC);
let cost_directive = cost_directive_name.and_then(|name| source.get(name.as_str()));
Expand Down Expand Up @@ -74,7 +74,7 @@ macro_rules! propagate_demand_control_directives_to_position {
subgraph_schema: &mut FederationSchema,
source: &Node<$source_ty>,
dest: &$dest_ty,
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let cost_directive_name = original_directive_names.get(&COST_DIRECTIVE_NAME_IN_SPEC);
let cost_directive =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use std::sync::Arc;
use apollo_compiler::ast::Argument;
use apollo_compiler::ast::Directive;
use apollo_compiler::ast::FieldDefinition;
use apollo_compiler::collections::IndexMap;
use apollo_compiler::collections::HashMap;
use apollo_compiler::collections::HashSet;
use apollo_compiler::collections::IndexSet;
use apollo_compiler::executable;
use apollo_compiler::name;
Expand Down Expand Up @@ -176,8 +177,8 @@ pub(crate) fn extract_subgraphs_from_supergraph(

type CollectEmptySubgraphsOk = (
FederationSubgraphs,
IndexMap<Name, &'static FederationSpecDefinition>,
IndexMap<Name, Arc<str>>,
HashMap<Name, &'static FederationSpecDefinition>,
HashMap<Name, Arc<str>>,
);
fn collect_empty_subgraphs(
supergraph_schema: &FederationSchema,
Expand All @@ -187,8 +188,8 @@ fn collect_empty_subgraphs(
let graph_directive_definition =
join_spec_definition.graph_directive_definition(supergraph_schema)?;
let graph_enum = join_spec_definition.graph_enum_definition(supergraph_schema)?;
let mut federation_spec_definitions = IndexMap::default();
let mut graph_enum_value_name_to_subgraph_name = IndexMap::default();
let mut federation_spec_definitions = HashMap::default();
let mut graph_enum_value_name_to_subgraph_name = HashMap::default();
for (enum_value_name, enum_value_definition) in graph_enum.values.iter() {
let graph_application = enum_value_definition
.directives
Expand Down Expand Up @@ -297,8 +298,8 @@ pub(crate) fn new_empty_fed_2_subgraph_schema() -> Result<FederationSchema, Fede

struct TypeInfo {
name: NamedType,
// IndexMap<subgraph_enum_value: String, is_interface_object: bool>
subgraph_info: IndexMap<Name, bool>,
// HashMap<subgraph_enum_value: String, is_interface_object: bool>
subgraph_info: HashMap<Name, bool>,
}

struct TypeInfos {
Expand Down Expand Up @@ -329,8 +330,8 @@ struct TypeInfos {
/// when a custom directive's name conflicts with that of a default one.
fn get_apollo_directive_names(
supergraph_schema: &FederationSchema,
) -> Result<IndexMap<Name, Name>, FederationError> {
let mut hm: IndexMap<Name, Name> = IndexMap::default();
) -> Result<HashMap<Name, Name>, FederationError> {
let mut hm: HashMap<Name, Name> = HashMap::default();
for directive in &supergraph_schema.schema().schema_definition.directives {
if directive.name.as_str() == "link" {
if let Ok(link) = Link::from_directive_application(directive) {
Expand All @@ -349,8 +350,8 @@ fn get_apollo_directive_names(
fn extract_subgraphs_from_fed_2_supergraph(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
join_spec_definition: &'static JoinSpecDefinition,
filtered_types: &Vec<TypeDefinitionPosition>,
) -> Result<(), FederationError> {
Expand Down Expand Up @@ -485,11 +486,11 @@ fn extract_subgraphs_from_fed_2_supergraph(
fn add_all_empty_subgraph_types(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
join_spec_definition: &'static JoinSpecDefinition,
filtered_types: &Vec<TypeDefinitionPosition>,
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<TypeInfos, FederationError> {
let type_directive_definition =
join_spec_definition.type_directive_definition(supergraph_schema)?;
Expand Down Expand Up @@ -579,8 +580,8 @@ fn add_empty_type(
type_definition_position: TypeDefinitionPosition,
type_directive_applications: &Vec<TypeDirectiveArguments>,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
) -> Result<TypeInfo, FederationError> {
// In fed2, we always mark all types with `@join__type` but making sure.
if type_directive_applications.is_empty() {
Expand All @@ -591,7 +592,7 @@ fn add_empty_type(
}
let mut type_info = TypeInfo {
name: type_definition_position.type_name().clone(),
subgraph_info: IndexMap::default(),
subgraph_info: HashMap::default(),
};
for type_directive_application in type_directive_applications {
let subgraph = get_subgraph(
Expand Down Expand Up @@ -787,11 +788,11 @@ fn add_empty_type(
fn extract_object_type_content(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
join_spec_definition: &JoinSpecDefinition,
info: &[TypeInfo],
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let field_directive_definition =
join_spec_definition.field_directive_definition(supergraph_schema)?;
Expand Down Expand Up @@ -963,11 +964,11 @@ fn extract_object_type_content(
fn extract_interface_type_content(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
join_spec_definition: &JoinSpecDefinition,
info: &[TypeInfo],
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let field_directive_definition =
join_spec_definition.field_directive_definition(supergraph_schema)?;
Expand All @@ -990,7 +991,7 @@ fn extract_interface_type_content(
.get(supergraph_schema.schema())?;
fn get_pos(
subgraph: &FederationSubgraph,
subgraph_info: &IndexMap<Name, bool>,
subgraph_info: &HashMap<Name, bool>,
graph_enum_value: &Name,
type_name: NamedType,
) -> Result<ObjectOrInterfaceTypeDefinitionPosition, FederationError> {
Expand Down Expand Up @@ -1159,7 +1160,7 @@ fn extract_interface_type_content(
fn extract_union_type_content(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
join_spec_definition: &JoinSpecDefinition,
info: &[TypeInfo],
) -> Result<(), FederationError> {
Expand Down Expand Up @@ -1251,11 +1252,11 @@ fn extract_union_type_content(
fn extract_enum_type_content(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
join_spec_definition: &JoinSpecDefinition,
info: &[TypeInfo],
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
// This was added in join 0.3, so it can genuinely be None.
let enum_value_directive_definition =
Expand Down Expand Up @@ -1360,11 +1361,11 @@ fn extract_enum_type_content(
fn extract_input_object_type_content(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
federation_spec_definitions: &IndexMap<Name, &'static FederationSpecDefinition>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
federation_spec_definitions: &HashMap<Name, &'static FederationSpecDefinition>,
join_spec_definition: &JoinSpecDefinition,
info: &[TypeInfo],
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let field_directive_definition =
join_spec_definition.field_directive_definition(supergraph_schema)?;
Expand Down Expand Up @@ -1471,7 +1472,7 @@ fn add_subgraph_field(
is_shareable: bool,
field_directive_application: Option<&FieldDirectiveArguments>,
cost_spec_definition: Option<&'static CostSpecDefinition>,
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let field_directive_application =
field_directive_application.unwrap_or_else(|| &FieldDirectiveArguments {
Expand Down Expand Up @@ -1586,7 +1587,7 @@ fn add_subgraph_input_field(
subgraph: &mut FederationSubgraph,
field_directive_application: Option<&FieldDirectiveArguments>,
cost_spec_definition: Option<&'static CostSpecDefinition>,
original_directive_names: &IndexMap<Name, Name>,
original_directive_names: &HashMap<Name, Name>,
) -> Result<(), FederationError> {
let field_directive_application =
field_directive_application.unwrap_or_else(|| &FieldDirectiveArguments {
Expand Down Expand Up @@ -1633,7 +1634,7 @@ fn decode_type(type_: &str) -> Result<Type, FederationError> {

fn get_subgraph<'subgraph>(
subgraphs: &'subgraph mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
graph_enum_value: &Name,
) -> Result<&'subgraph mut FederationSubgraph, FederationError> {
let subgraph_name = graph_enum_value_name_to_subgraph_name
Expand Down Expand Up @@ -1755,7 +1756,7 @@ impl IntoIterator for ValidFederationSubgraphs {
}

lazy_static! {
static ref EXECUTABLE_DIRECTIVE_LOCATIONS: IndexSet<DirectiveLocation> = {
static ref EXECUTABLE_DIRECTIVE_LOCATIONS: HashSet<DirectiveLocation> = {
[
DirectiveLocation::Query,
DirectiveLocation::Mutation,
Expand Down Expand Up @@ -2322,7 +2323,7 @@ static JOIN_DIRECTIVE: &str = "join__directive";
fn extract_join_directives(
supergraph_schema: &FederationSchema,
subgraphs: &mut FederationSubgraphs,
graph_enum_value_name_to_subgraph_name: &IndexMap<Name, Arc<str>>,
graph_enum_value_name_to_subgraph_name: &HashMap<Name, Arc<str>>,
) -> Result<(), FederationError> {
let join_directives = match supergraph_schema
.referencers()
Expand Down