use apollo_compiler::ast::{EnumTypeDefinition, ScalarTypeDefinition};
use once_cell::sync::Lazy;
use std::collections::HashMap;
use super::{Spec, SpecDirective, SpecStatus, SpecType, SpecsByVersion};
pub const LINK_SPEC_NAME: &str = "link";
pub const LINK_DIRECTIVE: &str = "link";
pub const LINK_DESCRIPTION: &str = "The [`@link`](https://www.apollographql.com/docs/federation/federated-schemas/federated-directives/#the-link-directive) directive links definitions from an external specification to this schema. Every Federation 2 subgraph uses the `@link` directive to import other specified directives.";
pub const IMPORT_SCALAR: &str = "Import";
pub const PURPOSE_ENUM: &str = "Purpose";
pub static LINK_SPECS_BY_VERSION: Lazy<SpecsByVersion> = {
Lazy::new(|| {
let import = SpecType::<ScalarTypeDefinition>::new(IMPORT_SCALAR);
let purpose = SpecType::<EnumTypeDefinition>::new("enum Purpose { EXECUTION SECURITY }");
let link_directive = SpecDirective::new(
"directive @link(url: String!, as: String, import: [Import!], for: Purpose) repeatable on SCHEMA", LINK_DESCRIPTION
);
let link1_0 = Spec {
status: SpecStatus::Supported,
scalars: HashMap::from([(IMPORT_SCALAR.to_string(), import)]),
input_types: HashMap::new(),
directives: HashMap::from([(LINK_DIRECTIVE.to_string(), link_directive)]),
enums: HashMap::from([(PURPOSE_ENUM.to_string(), purpose)]),
};
HashMap::from([("1.0".to_string(), link1_0)])
})
};