Skip to content

Commit

Permalink
return capabilities in /validate
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-hasura committed Nov 15, 2023
1 parent 7c7afcb commit 8ac617e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rust-connector-sdk/src/default_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ where
#[derive(Debug, Clone, Serialize)]
struct ValidateResponse {
schema: SchemaResponse,
capabilities: CapabilitiesResponse,
resolved_configuration: String,
}

Expand All @@ -585,6 +586,7 @@ struct ValidateResponse {
enum ValidateErrors {
InvalidConfiguration { ranges: Vec<InvalidRange> },
UnableToBuildSchema,
UnableToBuildCapabilities,
JsonEncodingError(String),
}

Expand Down Expand Up @@ -623,6 +625,24 @@ where
)
}
})?;
let capabilities =
C::get_capabilities()
.await
.into_value()
.map_err(|e: Box<dyn Error + Send + Sync>| {
tracing::error!(
meta.signal_type = "log",
event.domain = "ndc",
event.name = "Unable to build schema",
name = "Unable to build schema",
body = %e,
error = true,
);
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(ValidateErrors::UnableToBuildCapabilities),
)
})?;
let resolved_config_bytes = serde_json::to_vec(&configuration).map_err(|err| {
tracing::error!(
meta.signal_type = "log",
Expand All @@ -640,6 +660,7 @@ where
let resolved_configuration = general_purpose::STANDARD.encode(resolved_config_bytes);
Ok(Json(ValidateResponse {
schema,
capabilities,
resolved_configuration,
}))
}
Expand Down

0 comments on commit 8ac617e

Please sign in to comment.