diff --git a/src/core/config/config_module/fixtures/router.graphql b/src/core/config/config_module/fixtures/router.graphql index 5288226c3d..39ac02e37a 100644 --- a/src/core/config/config_module/fixtures/router.graphql +++ b/src/core/config/config_module/fixtures/router.graphql @@ -1,4 +1,4 @@ -schema { +schema @server(port: 8000) @upstream(httpCache: 42, batch: {delay: 100}) { # @link(src: "http://localhost:4000", type: SubGraph, meta: {name: "Users"}) # @link(src: "http://localhost:5000", type: SubGraph, meta: {name: "Posts"}) query: Query diff --git a/src/core/config/config_module/fixtures/subgraph-posts.graphql b/src/core/config/config_module/fixtures/subgraph-posts.graphql index ab6ff45aaf..615da04552 100644 --- a/src/core/config/config_module/fixtures/subgraph-posts.graphql +++ b/src/core/config/config_module/fixtures/subgraph-posts.graphql @@ -1,4 +1,4 @@ -schema @server(port: 8000) @upstream(httpCache: 42, batch: {delay: 100}) { +schema { query: Query } diff --git a/src/core/config/config_module/fixtures/subgraph-users.graphql b/src/core/config/config_module/fixtures/subgraph-users.graphql index 22f0e6b63a..a1ff68280a 100644 --- a/src/core/config/config_module/fixtures/subgraph-users.graphql +++ b/src/core/config/config_module/fixtures/subgraph-users.graphql @@ -1,4 +1,4 @@ -schema @server(port: 8000) @upstream(httpCache: 42, batch: {delay: 100}) { +schema { query: Query } diff --git a/src/core/config/config_module/merge.rs b/src/core/config/config_module/merge.rs index 5fc7fff0d7..6d0e3e1a12 100644 --- a/src/core/config/config_module/merge.rs +++ b/src/core/config/config_module/merge.rs @@ -4,10 +4,10 @@ use indexmap::IndexMap; use tailcall_valid::{Valid, Validator}; use super::{Cache, ConfigModule}; -use crate::core; -use crate::core::config::{Arg, Config, Enum, Field, Type}; +use crate::core::config::{Arg, Config, Enum, Field, RootSchema, Type}; use crate::core::merge_right::MergeRight; use crate::core::variance::{Contravariant, Covariant, Invariant}; +use crate::core::{self}; impl core::Type { fn merge(self, other: Self, non_null_merge: fn(bool, bool) -> bool) -> Valid { @@ -183,6 +183,24 @@ impl Covariant for Enum { } } +impl Invariant for RootSchema { + fn unify(self, other: Self) -> Valid { + fn unify_option(left: Option, right: Option) -> Option { + match (left, right) { + (None, None) => None, + (None, Some(that)) => Some(that), + (Some(this), _) => Some(this), + } + } + + Valid::succeed(Self { + query: unify_option(self.query, other.query), + mutation: unify_option(self.mutation, other.mutation), + subscription: unify_option(self.subscription, other.subscription), + }) + } +} + impl Invariant for Cache { fn unify(self, other: Self) -> Valid { let mut types = self.config.types; @@ -270,12 +288,18 @@ impl Invariant for Cache { .map(|en| (name, en)) .trace(&trace_name) })) - .map( |(merged_types, merged_enums)| { + .fuse(self.config.schema.unify(other.config.schema)) + .map( |(merged_types, merged_enums, schema)| { types.extend(merged_types); enums.extend(merged_enums); let config = Config { - types, enums, unions: self.config.unions.merge_right(other.config.unions), server: self.config.server.merge_right(other.config.server), upstream: self.config.upstream.merge_right(other.config.upstream), schema: self.config.schema.merge_right(other.config.schema), links: self.config.links.merge_right(other.config.links), telemetry: self.config.telemetry.merge_right(other.config.telemetry) }; + types, + enums, + unions: self.config.unions.merge_right(other.config.unions), + schema, + ..self.config + }; Cache { config, diff --git a/src/core/config/reader.rs b/src/core/config/reader.rs index 175291e865..675c6a9d42 100644 --- a/src/core/config/reader.rs +++ b/src/core/config/reader.rs @@ -1,10 +1,11 @@ use std::path::Path; +use futures_util::future::join_all; use rustls_pemfile; use rustls_pki_types::{ CertificateDer, PrivateKeyDer, PrivatePkcs1KeyDer, PrivatePkcs8KeyDer, PrivateSec1KeyDer, }; -use tailcall_valid::{Valid, Validator}; +use tailcall_valid::{Valid, ValidationError, Validator}; use url::Url; use super::{ConfigModule, Content, Link, LinkType, PrivateKey}; @@ -34,11 +35,10 @@ impl ConfigReader { } /// Reads the links in a Config and fill the content - #[async_recursion::async_recursion] async fn ext_links( &self, config_module: ConfigModule, - parent_dir: Option<&'async_recursion Path>, + parent_dir: Option<&Path>, ) -> anyhow::Result { let reader_ctx = ConfigReaderContext::new(&self.runtime); @@ -77,14 +77,6 @@ impl ConfigReader { config_module = config_module.and_then(|config_module| { config_module.unify(ConfigModule::from(config.clone())) }); - - if !config.links.is_empty() { - let cfg_module = self - .ext_links(ConfigModule::from(config), Path::new(&link.src).parent()) - .await?; - config_module = - config_module.and_then(|config_module| config_module.unify(cfg_module)); - } } LinkType::Protobuf => { let meta = self.proto_reader.read(path, None).await?; @@ -200,24 +192,32 @@ impl ConfigReader { .map(|file| file.render(&reader_ctx)) .collect::>(); - let mut config_module = Valid::succeed(ConfigModule::default()); - - for file in files.iter() { + let mut config_modules = join_all(files.iter().map(|file| async { let source = Source::detect(&file.path)?; let schema = &file.content; // Create initial config module - let new_config_module = self - .resolve( - Config::from_source(source, schema)?, - Path::new(&file.path).parent(), - ) - .await?; - - // Merge it with the original config set - config_module = - config_module.and_then(|config_module| config_module.unify(new_config_module)); - } + self.resolve( + Config::from_source(source, schema)?, + Path::new(&file.path).parent(), + ) + .await + })) + .await + .into_iter(); + + let config_module = Valid::from( + config_modules + .next() + .ok_or(anyhow::anyhow!("At least one config should be defined"))? + .map_err(to_validation_error), + ); + + let config_module = config_modules.fold(config_module, |acc, other| { + acc.and_then(|cfg| { + Valid::from(other.map_err(to_validation_error)).and_then(|other| cfg.unify(other)) + }) + }); Ok(config_module.to_result()?) } @@ -256,6 +256,13 @@ impl ConfigReader { } } +fn to_validation_error(error: anyhow::Error) -> ValidationError { + match error.downcast::>() { + Ok(err) => err, + Err(err) => ValidationError::new(err.to_string()), + } +} + #[cfg(test)] mod reader_tests { use std::path::{Path, PathBuf}; diff --git a/tests/core/snapshots/https.md_0.snap b/tests/core/snapshots/https.md_0.snap deleted file mode 100644 index a085a7c561..0000000000 --- a/tests/core/snapshots/https.md_0.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: tests/core/spec.rs -expression: response ---- -{ - "status": 200, - "headers": { - "content-type": "application/json" - }, - "body": { - "data": { - "firstUser": { - "name": "Leanne Graham" - } - } - } -} diff --git a/tests/core/snapshots/https.md_client.snap b/tests/core/snapshots/https.md_client.snap deleted file mode 100644 index 2215e476ec..0000000000 --- a/tests/core/snapshots/https.md_client.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatted ---- -type Query { - firstUser: User -} - -type User { - id: Int - name: String -} - -schema { - query: Query -} diff --git a/tests/core/snapshots/https.md_merged.snap b/tests/core/snapshots/https.md_merged.snap deleted file mode 100644 index 8868c6973d..0000000000 --- a/tests/core/snapshots/https.md_merged.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server @upstream { - query: Query -} - -type Query { - firstUser: User @http(url: "http://jsonplaceholder.typicode.com/users/1") -} - -type User { - id: Int - name: String -} diff --git a/tests/core/snapshots/test-nested-link.md_client.snap b/tests/core/snapshots/merge-linked-config.md_client.snap similarity index 83% rename from tests/core/snapshots/test-nested-link.md_client.snap rename to tests/core/snapshots/merge-linked-config.md_client.snap index a1839b52b8..d46a44fd2d 100644 --- a/tests/core/snapshots/test-nested-link.md_client.snap +++ b/tests/core/snapshots/merge-linked-config.md_client.snap @@ -1,10 +1,10 @@ --- source: tests/core/spec.rs expression: formatted +snapshot_kind: text --- -enum Foo { - BAR - BAZ +type Foo { + foo: String } type Post { diff --git a/tests/core/snapshots/test-nested-link.md_merged.snap b/tests/core/snapshots/merge-linked-config.md_merged.snap similarity index 68% rename from tests/core/snapshots/test-nested-link.md_merged.snap rename to tests/core/snapshots/merge-linked-config.md_merged.snap index 02fdc7e986..a0eed4f4f4 100644 --- a/tests/core/snapshots/test-nested-link.md_merged.snap +++ b/tests/core/snapshots/merge-linked-config.md_merged.snap @@ -1,19 +1,18 @@ --- source: tests/core/spec.rs expression: formatter +snapshot_kind: text --- schema - @server - @upstream - @link(src: "graphql-with-link.graphql", type: Config) - @link(src: "link-enum.graphql", type: Config) - @link(src: "link-enum.graphql", type: Config) { + @server(port: 8000) + @upstream(batch: {delay: 10, headers: []}, httpCache: 10) + @link(src: "link-1.graphql", type: Config) + @link(src: "link-2.graphql", type: Config) { query: Query } -enum Foo { - BAR - BAZ +type Foo { + foo: String } type Post { diff --git a/tests/core/snapshots/on-request-body-grpc.md_0.snap b/tests/core/snapshots/on-request-body-grpc.md_0.snap deleted file mode 100644 index b686744d7c..0000000000 --- a/tests/core/snapshots/on-request-body-grpc.md_0.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: tests/core/spec.rs -expression: response ---- -{ - "status": 200, - "headers": { - "content-type": "application/json" - }, - "body": { - "data": { - "newsById": { - "id": 2, - "title": "Note 2 - Changed by JS" - } - } - } -} diff --git a/tests/core/snapshots/on-request-body-grpc.md_client.snap b/tests/core/snapshots/on-request-body-grpc.md_client.snap deleted file mode 100644 index 3040174250..0000000000 --- a/tests/core/snapshots/on-request-body-grpc.md_client.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatted ---- -type News { - body: String - id: Int - postImage: String - title: String -} - -type Query { - newsById: News! -} - -schema { - query: Query -} diff --git a/tests/core/snapshots/on-request-body-grpc.md_merged.snap b/tests/core/snapshots/on-request-body-grpc.md_merged.snap deleted file mode 100644 index c72cde554c..0000000000 --- a/tests/core/snapshots/on-request-body-grpc.md_merged.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema - @server(port: 8000) - @upstream - @link(src: "test.js", type: Script) - @link(id: "news", src: "news.proto", type: Protobuf) { - query: Query -} - -type News { - body: String - id: Int - postImage: String - title: String -} - -type Query { - newsById: News! - @grpc( - url: "http://localhost:50051" - body: {id: 2} - method: "news.NewsService.GetNews" - onResponseBody: "onResponse" - ) -} diff --git a/tests/core/snapshots/recursive-types-json.md_0.snap b/tests/core/snapshots/recursive-types-json.md_0.snap deleted file mode 100644 index f92af42448..0000000000 --- a/tests/core/snapshots/recursive-types-json.md_0.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: tests/core/spec.rs -expression: response ---- -{ - "status": 200, - "headers": { - "content-type": "application/json" - }, - "body": { - "data": { - "user": { - "name": "User1", - "id": 1, - "connections": [ - { - "type": "friend", - "user": { - "name": "User2", - "id": 2, - "connections": [ - { - "user": { - "name": "User3", - "id": 3 - } - }, - { - "user": { - "name": "User4", - "id": 4 - } - } - ] - } - } - ] - } - } - } -} diff --git a/tests/core/snapshots/recursive-types-json.md_1.snap b/tests/core/snapshots/recursive-types-json.md_1.snap deleted file mode 100644 index cb47da11fe..0000000000 --- a/tests/core/snapshots/recursive-types-json.md_1.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: tests/core/spec.rs -expression: response ---- -{ - "status": 200, - "headers": { - "content-type": "application/json" - }, - "body": { - "data": { - "createUser": { - "name": "NewUser", - "id": 111, - "connections": [ - { - "type": "friend", - "user": { - "name": "User1", - "id": 1 - } - } - ] - } - } - } -} diff --git a/tests/core/snapshots/recursive-types-json.md_client.snap b/tests/core/snapshots/recursive-types-json.md_client.snap deleted file mode 100644 index d88545ef2e..0000000000 --- a/tests/core/snapshots/recursive-types-json.md_client.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatted ---- -type Connection { - type: String - user: User -} - -input ConnectionInput { - type: String - user: UserInput -} - -type Mutation { - createUser(user: UserInput): User -} - -type Query { - user: User -} - -type User { - connections: [Connection] - id: Int! - name: String! -} - -input UserInput { - connections: [ConnectionInput] - id: Int! - name: String! -} - -schema { - query: Query - mutation: Mutation -} diff --git a/tests/core/snapshots/recursive-types-json.md_merged.snap b/tests/core/snapshots/recursive-types-json.md_merged.snap deleted file mode 100644 index 7722b453d6..0000000000 --- a/tests/core/snapshots/recursive-types-json.md_merged.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server @upstream(httpCache: 42) { - query: Query - mutation: Mutation -} - -input ConnectionInput { - type: String - user: UserInput -} - -input UserInput { - connections: [ConnectionInput] @http(url: "http://jsonplaceholder.typicode.com/connections/{{.value.id}}") - id: Int! - name: String! -} - -type Connection { - type: String - user: User -} - -type Mutation { - createUser(user: UserInput): User - @http(url: "http://jsonplaceholder.typicode.com/user", body: "{{.args.user}}", method: "POST") -} - -type Query { - user: User @http(url: "http://jsonplaceholder.typicode.com/users/1") -} - -type User { - connections: [Connection] @http(url: "http://jsonplaceholder.typicode.com/connections/{{.value.id}}") - id: Int! - name: String! -} diff --git a/tests/core/snapshots/test-conflict-allowed-headers.md_merged.snap b/tests/core/snapshots/test-conflict-allowed-headers.md_merged.snap deleted file mode 100644 index d3aa18973c..0000000000 --- a/tests/core/snapshots/test-conflict-allowed-headers.md_merged.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server @upstream(allowedHeaders: ["a", "b", "c", "d"]) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} diff --git a/tests/core/snapshots/test-conflict-vars.md_merged.snap b/tests/core/snapshots/test-conflict-vars.md_merged.snap deleted file mode 100644 index 5dfdeaaabb..0000000000 --- a/tests/core/snapshots/test-conflict-vars.md_merged.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server(vars: [{key: "a", value: "b"}, {key: "c", value: "d"}, {key: "p", value: "q"}]) @upstream { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} diff --git a/tests/core/snapshots/test-interface-from-json.md_client.snap b/tests/core/snapshots/test-interface-from-json.md_client.snap deleted file mode 100644 index ed99fa7b6d..0000000000 --- a/tests/core/snapshots/test-interface-from-json.md_client.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatted ---- -type B implements IA { - a: String - b: String -} - -interface IA { - a: String -} - -type Query { - bar: B -} - -schema { - query: Query -} diff --git a/tests/core/snapshots/test-interface-from-json.md_merged.snap b/tests/core/snapshots/test-interface-from-json.md_merged.snap deleted file mode 100644 index 862f3e1cf3..0000000000 --- a/tests/core/snapshots/test-interface-from-json.md_merged.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server @upstream { - query: Query -} - -interface IA { - a: String -} - -type B implements IA { - a: String - b: String -} - -type Query { - bar: B @http(url: "http://jsonplaceholder.typicode.com/posts") -} diff --git a/tests/core/snapshots/test-merge-batch.md_merged.snap b/tests/core/snapshots/test-merge-batch.md_merged.snap deleted file mode 100644 index 9fbe79d5e4..0000000000 --- a/tests/core/snapshots/test-merge-batch.md_merged.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server @upstream(batch: {delay: 5, headers: ["a", "b", "c"], maxSize: 100}) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} diff --git a/tests/core/snapshots/test-merge-query.md_merged.snap b/tests/core/snapshots/test-merge-query.md_merged.snap deleted file mode 100644 index 6f9a054135..0000000000 --- a/tests/core/snapshots/test-merge-query.md_merged.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server(port: 8000) @upstream(proxy: {url: "http://localhost:3000"}) { - query: Query -} - -type Query { - hello: String @expr(body: "world") - hi: String @expr(body: "world") -} diff --git a/tests/core/snapshots/test-response-header-merge.md_merged.snap b/tests/core/snapshots/test-response-header-merge.md_merged.snap deleted file mode 100644 index 11630662de..0000000000 --- a/tests/core/snapshots/test-response-header-merge.md_merged.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server(headers: {custom: [{key: "a", value: "a"}, {key: "a", value: "b"}]}) @upstream { - query: Query -} - -type Query { - user: User @expr(body: {name: "John"}) -} - -type User { - age: Int - name: String -} diff --git a/tests/core/snapshots/test-server-base-types.md_merged.snap b/tests/core/snapshots/test-server-base-types.md_merged.snap deleted file mode 100644 index 28376478fc..0000000000 --- a/tests/core/snapshots/test-server-base-types.md_merged.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server(port: 8000) @upstream(proxy: {url: "http://localhost:3000"}) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} diff --git a/tests/core/snapshots/test-static-value.md_0.snap b/tests/core/snapshots/test-static-value.md_0.snap deleted file mode 100644 index a085a7c561..0000000000 --- a/tests/core/snapshots/test-static-value.md_0.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: tests/core/spec.rs -expression: response ---- -{ - "status": 200, - "headers": { - "content-type": "application/json" - }, - "body": { - "data": { - "firstUser": { - "name": "Leanne Graham" - } - } - } -} diff --git a/tests/core/snapshots/test-static-value.md_client.snap b/tests/core/snapshots/test-static-value.md_client.snap deleted file mode 100644 index 2215e476ec..0000000000 --- a/tests/core/snapshots/test-static-value.md_client.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatted ---- -type Query { - firstUser: User -} - -type User { - id: Int - name: String -} - -schema { - query: Query -} diff --git a/tests/core/snapshots/test-static-value.md_merged.snap b/tests/core/snapshots/test-static-value.md_merged.snap deleted file mode 100644 index 8868c6973d..0000000000 --- a/tests/core/snapshots/test-static-value.md_merged.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: tests/core/spec.rs -expression: formatter ---- -schema @server @upstream { - query: Query -} - -type Query { - firstUser: User @http(url: "http://jsonplaceholder.typicode.com/users/1") -} - -type User { - id: Int - name: String -} diff --git a/tests/core/spec.rs b/tests/core/spec.rs index 4170bb42bb..56a569da2b 100644 --- a/tests/core/spec.rs +++ b/tests/core/spec.rs @@ -220,10 +220,12 @@ async fn test_spec(spec: ExecutionSpec) { })) }) .and_then(|cfgs| { - cfgs.into_iter() - .fold(Valid::succeed(ConfigModule::default()), |acc, c| { - acc.and_then(|acc| acc.unify(c.clone())) - }) + let mut cfgs = cfgs.into_iter(); + let config_module = cfgs.next().expect("At least one config should be defined"); + + cfgs.fold(Valid::succeed(config_module.clone()), |acc, c| { + acc.and_then(|acc| acc.unify(c.clone())) + }) }) // Apply required transformers to the configuration .and_then(|cfg| cfg.transform(Required)); diff --git a/tests/execution/merge-linked-config.md b/tests/execution/merge-linked-config.md new file mode 100644 index 0000000000..f5de4c41bc --- /dev/null +++ b/tests/execution/merge-linked-config.md @@ -0,0 +1,49 @@ +# Merge linked configs + +Merge should happen only on schema while configurations like schema, upstream, telemetry should be defined only by the root config + +```graphql @file:link-1.graphql +schema @server(port: 3000) @upstream(httpCache: 42, batch: {delay: 22}) { + query: Query +} + +type Foo { + foo: String +} + +type Query { + foo: Foo @http(url: "http://jsonplaceholder.typicode.com/foo") +} +``` + +```graphql @file:link-2.graphql +schema @server(port: 4000) @upstream(httpCache: 33, batch: {delay: 48}) { + query: Query +} + +type Post { + id: Int! + userId: Int! + user: User + @graphQL(url: "http://jsonplaceholder.typicode.com", args: [{key: "id", value: "{{.value.userId}}"}], name: "user") +} + +type Query { + post(id: Int!): Post @http(url: "http://jsonplaceholder.typicode.com/posts/{{.args.id}}") +} + +type User { + id: Int + name: String +} +``` + +```graphql @config +schema + @server(port: 8000) + @upstream(httpCache: 10, batch: {delay: 10}) + @link(src: "link-1.graphql", type: Config) + @link(src: "link-2.graphql", type: Config) { + query: Query +} +``` diff --git a/tests/execution/test-conflict-allowed-headers.md b/tests/execution/test-conflict-allowed-headers.md deleted file mode 100644 index bab99fb9df..0000000000 --- a/tests/execution/test-conflict-allowed-headers.md +++ /dev/null @@ -1,21 +0,0 @@ -# test-conflict-allowed-headers - -```graphql @config -schema @server @upstream(allowedHeaders: ["a", "b", "c"]) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` - -```graphql @config -schema @server @upstream(allowedHeaders: ["b", "c", "d"]) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` diff --git a/tests/execution/test-conflict-vars.md b/tests/execution/test-conflict-vars.md deleted file mode 100644 index e1253cecfe..0000000000 --- a/tests/execution/test-conflict-vars.md +++ /dev/null @@ -1,21 +0,0 @@ -# test-conflict-vars - -```graphql @config -schema @server(vars: [{key: "a", value: "b"}, {key: "c", value: "d"}]) @upstream { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` - -```graphql @config -schema @server(vars: [{key: "a", value: "b"}, {key: "p", value: "q"}]) @upstream { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` diff --git a/tests/execution/test-merge-batch.md b/tests/execution/test-merge-batch.md deleted file mode 100644 index 875b222da7..0000000000 --- a/tests/execution/test-merge-batch.md +++ /dev/null @@ -1,31 +0,0 @@ -# test-merge-batch - -```graphql @config -schema @server @upstream(batch: {delay: 0, maxSize: 1000, headers: ["a", "b"]}) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` - -```graphql @config -schema @server @upstream(batch: {delay: 5, maxSize: 100, headers: ["b", "c"]}) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` - -```graphql @config -schema @server @upstream { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` diff --git a/tests/execution/test-merge-query.md b/tests/execution/test-merge-query.md deleted file mode 100644 index 2ff91c33ba..0000000000 --- a/tests/execution/test-merge-query.md +++ /dev/null @@ -1,21 +0,0 @@ -# test-merge-query - -```graphql @config -schema @server(port: 3000) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` - -```graphql @config -schema @server(port: 8000) @upstream(proxy: {url: "http://localhost:3000"}) { - query: Query -} - -type Query { - hi: String @expr(body: "world") -} -``` diff --git a/tests/execution/test-nested-link.md b/tests/execution/test-nested-link.md deleted file mode 100644 index 19e9ad8fd0..0000000000 --- a/tests/execution/test-nested-link.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -identity: true ---- - -# test-nested-link - -```graphql @file:link-enum.graphql -schema @server @upstream { - query: Query -} - -enum Foo { - BAR - BAZ -} - -type Query { - foo: Foo @http(url: "http://jsonplaceholder.typicode.com/foo") -} -``` - -```graphql @file:graphql-with-link.graphql -schema @server @link(src: "link-enum.graphql", type: Config) { - query: Query -} - -type Post { - id: Int! - userId: Int! - user: User - @graphQL(url: "http://jsonplaceholder.typicode.com", args: [{key: "id", value: "{{.value.userId}}"}], name: "user") -} - -type Query { - post(id: Int!): Post @http(url: "http://jsonplaceholder.typicode.com/posts/{{.args.id}}") -} - -type User { - id: Int - name: String -} -``` - -```graphql @config -schema @server @upstream @link(src: "graphql-with-link.graphql", type: Config) { - query: Query -} -``` diff --git a/tests/execution/test-response-header-merge.md b/tests/execution/test-response-header-merge.md deleted file mode 100644 index 2c7697401e..0000000000 --- a/tests/execution/test-response-header-merge.md +++ /dev/null @@ -1,31 +0,0 @@ -# test-response-header-value - -```graphql @config -schema @server(headers: {custom: [{key: "a", value: "a"}]}) { - query: Query -} - -type User { - name: String - age: Int -} - -type Query { - user: User @expr(body: {name: "John"}) -} -``` - -```graphql @config -schema @server(headers: {custom: [{key: "a", value: "b"}]}) { - query: Query -} - -type User { - name: String - age: Int -} - -type Query { - user: User @expr(body: {name: "John"}) -} -``` diff --git a/tests/execution/test-server-base-types.md b/tests/execution/test-server-base-types.md deleted file mode 100644 index d67c359d14..0000000000 --- a/tests/execution/test-server-base-types.md +++ /dev/null @@ -1,21 +0,0 @@ -# test-server-base-types - -```graphql @config -schema @server(port: 3000) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -``` - -```graphql @config -schema @server(port: 8000) @upstream(proxy: {url: "http://localhost:3000"}) { - query: Query -} - -type Query { - hello: String @expr(body: "world") -} -```