Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend-api): Add get_app_by_id_opt #4443

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions lib/backend-api/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,31 @@ pub async fn get_app_by_id(
client: &WasmerClient,
app_id: String,
) -> 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(
types::GetDeployAppByIdVars {
app_id: app_id.into(),
},
))
.await?
.app
.context("app not found")?
.into_deploy_app()
.context("app conversion failed")
.app;

if let Some(app) = app_opt {
let app = app.into_deploy_app().context("app conversion failed")?;
Ok(Some(app))
} else {
Ok(None)
}
}

/// Retrieve an app together with a specific version.
Expand Down
Loading