apollo_supergraph/
database.rs

1use crate::{Supergraph, SupergraphError};
2use apollo_at_link::{
3    database::links_metadata,
4    link::Link,
5    spec::{Identity, APOLLO_SPEC_DOMAIN},
6};
7use apollo_compiler::Schema;
8use apollo_subgraph::Subgraphs;
9use std::sync::Arc;
10
11// TODO: we should define this as part as some more generic "JoinSpec" definition, but need
12// to define the ground work for that in `apollo-at-link` first.
13pub fn join_link_identity() -> Identity {
14    Identity {
15        domain: APOLLO_SPEC_DOMAIN.to_string(),
16        name: "join".to_string(),
17    }
18}
19
20pub fn join_link(schema: &Schema) -> Arc<Link> {
21    links_metadata(schema)
22        // TODO: error handling?
23        .unwrap_or_default()
24        .unwrap_or_default()
25        .for_identity(&join_link_identity())
26        .expect("The presence of the join link should have been validated on construction")
27}
28
29pub fn extract_subgraphs(_supergraph: &Supergraph) -> Result<Subgraphs, SupergraphError> {
30    // TODO
31    Ok(Subgraphs::new())
32}