Skip to content

Commit

Permalink
avoid printing empty headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Apr 15, 2024
1 parent a356065 commit ac6819e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
7 changes: 5 additions & 2 deletions generated/.tailcallrc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@
"minimum": 0.0
},
"headers": {
"default": [],
"type": "array",
"default": null,
"type": [
"array",
"null"
],
"items": {
"type": "string"
},
Expand Down
7 changes: 6 additions & 1 deletion src/config/into_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>(),
kind,
Expand Down
4 changes: 2 additions & 2 deletions src/config/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use crate::merge_right::MergeRight;
#[serde(rename_all = "camelCase", default)]
pub struct Batch {
pub delay: usize,
pub headers: BTreeSet<String>,
pub headers: Option<BTreeSet<String>>,
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 }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lambda/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions tests/execution_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ac6819e

Please sign in to comment.