From ac6819ef0b417ea07875781145f3bfd09ee4d98f Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Mon, 15 Apr 2024 14:06:18 +0530 Subject: [PATCH] avoid printing empty headers --- generated/.tailcallrc.schema.json | 7 +++++-- src/config/into_document.rs | 7 ++++++- src/config/upstream.rs | 4 ++-- src/lambda/io.rs | 4 ++-- tests/execution_spec.rs | 6 +++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/generated/.tailcallrc.schema.json b/generated/.tailcallrc.schema.json index 2843d575db..1530e70db5 100644 --- a/generated/.tailcallrc.schema.json +++ b/generated/.tailcallrc.schema.json @@ -162,8 +162,11 @@ "minimum": 0.0 }, "headers": { - "default": [], - "type": "array", + "default": null, + "type": [ + "array", + "null" + ], "items": { "type": "string" }, diff --git a/src/config/into_document.rs b/src/config/into_document.rs index d7c244a15d..7a782130a6 100644 --- a/src/config/into_document.rs +++ b/src/config/into_document.rs @@ -215,7 +215,12 @@ fn config_document(config: &ConfigModule) -> ServiceDocument { .as_ref() .map(|cache| pos(cache.to_directive())), ) - .chain(type_def.protected.as_ref().map(|protected| pos(protected.to_directive()))) + .chain( + type_def + .protected + .as_ref() + .map(|protected| pos(protected.to_directive())), + ) .chain(type_def.tag.as_ref().map(|tag| pos(tag.to_directive()))) .collect::>(), kind, diff --git a/src/config/upstream.rs b/src/config/upstream.rs index 47e8d9b367..b960102779 100644 --- a/src/config/upstream.rs +++ b/src/config/upstream.rs @@ -10,13 +10,13 @@ use crate::merge_right::MergeRight; #[serde(rename_all = "camelCase", default)] pub struct Batch { pub delay: usize, - pub headers: BTreeSet, + pub headers: Option>, pub max_size: usize, } impl Default for Batch { fn default() -> Self { - Batch { max_size: 100, delay: 0, headers: BTreeSet::new() } + Batch { max_size: 100, delay: 0, headers: None } } } diff --git a/src/lambda/io.rs b/src/lambda/io.rs index 97d101b379..c7f127e8fd 100644 --- a/src/lambda/io.rs +++ b/src/lambda/io.rs @@ -235,7 +235,7 @@ async fn execute_grpc_request_with_dl< .clone() .map(|s| s.headers) .unwrap_or_default(); - let endpoint_key = grpc::DataLoaderRequest::new(rendered, headers); + let endpoint_key = grpc::DataLoaderRequest::new(rendered, headers.unwrap_or_default()); Ok(data_loader .unwrap() @@ -261,7 +261,7 @@ async fn execute_request_with_dl< .clone() .map(|s| s.headers) .unwrap_or_default(); - let endpoint_key = crate::http::DataLoaderRequest::new(req, headers); + let endpoint_key = crate::http::DataLoaderRequest::new(req, headers.unwrap_or_default()); Ok(data_loader .unwrap() diff --git a/tests/execution_spec.rs b/tests/execution_spec.rs index ccde6fe67c..c22c107185 100644 --- a/tests/execution_spec.rs +++ b/tests/execution_spec.rs @@ -891,9 +891,9 @@ async fn assert_spec(spec: ExecutionSpec, opentelemetry: &InMemoryTelemetry) { ); } else { tracing::warn!( - "Spec {:#?} has \"check identity\" enabled, but its config isn't in GraphQL.", - spec.path - ); + "Spec {:#?} has \"check identity\" enabled, but its config isn't in GraphQL.", + spec.path + ); } server.push(config);