Skip to content

Commit

Permalink
Completely remove subgraph section of yaml.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryn committed Mar 9, 2022
1 parent c5f9559 commit a2c1a1e
Show file tree
Hide file tree
Showing 32 changed files with 91 additions and 239 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ futures = { version = "0.3.21", features = ["thread-pool"] }
hotwatch = "0.4.6"
http = "0.2.6"
hyper = { version = "0.14.17", features = ["server"] }
itertools = "0.10.3"
once_cell = "1.9.0"
opentelemetry = { version = "0.17.0", features = ["rt-tokio", "serialize"] }
opentelemetry-jaeger = { version = "0.16.0", features = [
Expand Down
48 changes: 4 additions & 44 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
//! Logic for loading configuration in to an object model
use apollo_router_core::plugins;
use apollo_router_core::prelude::*;
use derivative::Derivative;
use displaydoc::Display;
use itertools::Itertools;
use schemars::gen::SchemaGenerator;
use schemars::schema::{ObjectValidation, Schema, SchemaObject, SubschemaValidation};
use schemars::{JsonSchema, Set};
use serde::{Deserialize, Serialize};
use serde_json::Map;
use serde_json::Value;
use std::collections::HashMap;
use std::fmt;
use std::net::SocketAddr;
use std::path::PathBuf;
Expand Down Expand Up @@ -60,11 +59,6 @@ pub struct Configuration {
#[builder(default)]
pub server: Server,

/// Mapping of name to subgraph that the router may contact.
#[serde(default)]
#[builder(default)]
pub subgraphs: HashMap<String, SubgraphConf>,

/// Plugin configuration
#[serde(default)]
#[builder(default)]
Expand All @@ -76,13 +70,6 @@ fn default_listen() -> ListenAddr {
}

impl Configuration {
pub fn load_subgraphs(&self, schema: &graphql::Schema) -> HashMap<String, SubgraphConf> {
schema
.subgraphs()
.map(|(name, _subgraph_url)| (name.to_owned(), SubgraphConf {}))
.collect()
}

pub fn boxed(self) -> Box<Self> {
Box::new(self)
}
Expand Down Expand Up @@ -115,6 +102,7 @@ impl JsonSchema for Plugins {

let plugins = plugins()
.iter()
.sorted_by_key(|(name, _)| *name)
.map(|(name, factory)| (name.to_string(), factory.create_schema(gen)))
.collect::<schemars::Map<String, Schema>>();
let plugins_refs = plugins
Expand Down Expand Up @@ -146,23 +134,6 @@ impl JsonSchema for Plugins {
}
}

/// Configuration for a subgraph.
#[derive(Debug, Clone, Deserialize, Serialize, TypedBuilder)]
pub struct SubgraphConf {}

impl JsonSchema for SubgraphConf {
fn schema_name() -> String {
stringify!(Subgraph).to_string()
}

fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
// This is a manual implementation of Subgraph schema to allow layers that have been registered at
// compile time to be picked up.
let subgraph = SchemaObject::default();
Schema::Object(subgraph)
}
}

/// Configuration options pertaining to the http server component.
#[derive(Debug, Clone, Deserialize, Serialize, TypedBuilder, JsonSchema)]
#[serde(deny_unknown_fields)]
Expand Down Expand Up @@ -358,10 +329,12 @@ impl TlsConfig {
#[cfg(test)]
mod tests {
use super::*;
use apollo_router_core::prelude::*;
use apollo_router_core::SchemaError;
use insta::assert_json_snapshot;
use reqwest::Url;
use schemars::gen::SchemaSettings;
use std::collections::HashMap;

macro_rules! assert_config_snapshot {
($file:expr) => {{
Expand Down Expand Up @@ -438,18 +411,6 @@ mod tests {

#[test]
fn routing_url_in_schema() {
let configuration = Configuration::builder()
.subgraphs(
[
("inventory".to_string(), SubgraphConf {}),
("products".to_string(), SubgraphConf {}),
]
.iter()
.cloned()
.collect(),
)
.build();

let schema: graphql::Schema = r#"
schema
@core(feature: "https://specs.apollo.dev/core/v0.1"),
Expand All @@ -474,7 +435,6 @@ mod tests {
.parse()
.unwrap();

let _subgraphs = configuration.load_subgraphs(&schema);
let subgraphs: HashMap<&String, &Url> = schema.subgraphs().collect();

// if no configuration override, use the URL from the supergraph
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 395
assertion_line: 366
expression: config

---
Expand All @@ -19,7 +19,5 @@ server:
methods:
- foo
- bar
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 396
assertion_line: 367
expression: config

---
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 397
assertion_line: 368
expression: config

---
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 394
assertion_line: 365
expression: config

---
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 423
assertion_line: 394
expression: config

---
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 422
assertion_line: 393
expression: config

---
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ expression: config
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example:
layers: []
plugins: {}

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ expression: config
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example:
layers: []
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 436
assertion_line: 407
expression: config

---
server:
listen: "1.2.3.4:5"
cors: ~
subgraphs:
example: {}
plugins: {}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 384
assertion_line: 355
expression: "&schema"

---
Expand All @@ -22,26 +22,28 @@ expression: "&schema"
"cors": null
},
"$ref": "#/definitions/Server"
},
"subgraphs": {
"description": "Mapping of name to subgraph that the router may contact.",
"default": {},
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Subgraph"
}
}
},
"additionalProperties": false,
"definitions": {
"Conf": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
"graph": {
"$ref": "#/definitions/StudioGraph",
"nullable": true
},
"opentelemetry": {
"$ref": "#/definitions/OpenTelemetry",
"nullable": true
},
"opentracing": {
"$ref": "#/definitions/OpenTracingConfig",
"nullable": true
},
"spaceport": {
"$ref": "#/definitions/SpaceportConfig",
"nullable": true
}
}
},
Expand Down Expand Up @@ -153,6 +155,20 @@ expression: "&schema"
}
]
},
"OpenTelemetry": {
"$ref": "#/definitions/OpenTelemetry"
},
"OpenTracingConfig": {
"type": "object",
"required": [
"format"
],
"properties": {
"format": {
"$ref": "#/definitions/PropagationFormat"
}
}
},
"Operation": {
"oneOf": [
{
Expand Down Expand Up @@ -305,6 +321,13 @@ expression: "&schema"
}
]
},
"PropagationFormat": {
"type": "string",
"enum": [
"jaeger",
"zipkin_b3"
]
},
"Remove": {
"oneOf": [
{
Expand Down Expand Up @@ -351,6 +374,28 @@ expression: "&schema"
},
"additionalProperties": false
},
"Subgraph": {}
"SpaceportConfig": {
"type": "object",
"required": [
"external"
],
"properties": {
"collector": {
"default": "https://127.0.0.1:50051",
"type": "string"
},
"external": {
"type": "boolean"
},
"listener": {
"default": "127.0.0.1:50051",
"type": "string"
}
},
"additionalProperties": false
},
"StudioGraph": {
"type": "object"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 389
assertion_line: 360
expression: config

---
Expand All @@ -17,10 +17,5 @@ server:
methods:
- GET
- PUT
subgraphs:
accounts: {}
inventory: {}
products: {}
reviews: {}
plugins: {}

3 changes: 0 additions & 3 deletions apollo-router/src/configuration/testdata/config_basic.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
server:
listen: 1.2.3.4:5
subgraphs:
example:
routing_url: http://foo
Loading

0 comments on commit a2c1a1e

Please sign in to comment.