mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
feat(backend-api): Add get_app_by_id_opt
This commit is contained in:
committed by
Christoph Herzog
parent
f3f38df4e2
commit
088196a334
@@ -275,17 +275,31 @@ pub async fn get_app_by_id(
|
|||||||
client: &WasmerClient,
|
client: &WasmerClient,
|
||||||
app_id: String,
|
app_id: String,
|
||||||
) -> Result<DeployApp, anyhow::Error> {
|
) -> Result<DeployApp, anyhow::Error> {
|
||||||
client
|
get_app_by_id_opt(client, app_id)
|
||||||
|
.await?
|
||||||
|
.context("app not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieve an app by its global id.
|
||||||
|
pub async fn get_app_by_id_opt(
|
||||||
|
client: &WasmerClient,
|
||||||
|
app_id: String,
|
||||||
|
) -> Result<Option<DeployApp>, anyhow::Error> {
|
||||||
|
let app_opt = client
|
||||||
.run_graphql(types::GetDeployAppById::build(
|
.run_graphql(types::GetDeployAppById::build(
|
||||||
types::GetDeployAppByIdVars {
|
types::GetDeployAppByIdVars {
|
||||||
app_id: app_id.into(),
|
app_id: app_id.into(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.await?
|
.await?
|
||||||
.app
|
.app;
|
||||||
.context("app not found")?
|
|
||||||
.into_deploy_app()
|
if let Some(app) = app_opt {
|
||||||
.context("app conversion failed")
|
let app = app.into_deploy_app().context("app conversion failed")?;
|
||||||
|
Ok(Some(app))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve an app together with a specific version.
|
/// Retrieve an app together with a specific version.
|
||||||
|
|||||||
Reference in New Issue
Block a user