feat(backend-api): Add get_package_release query and types

This commit is contained in:
Christoph Herzog
2024-04-09 16:13:59 +02:00
parent 5800991767
commit 4368155959
3 changed files with 116 additions and 39 deletions

View File

@@ -612,6 +612,22 @@ pub async fn get_package_versions(
Ok(res.all_package_versions)
}
/// Retrieve a package release by hash.
pub async fn get_package_release(
client: &WasmerClient,
hash: &str,
) -> Result<Option<types::PackageWebc>, anyhow::Error> {
let hash = hash.trim_start_matches("sha256:");
client
.run_graphql_strict(types::GetPackageRelease::build(
types::GetPackageReleaseVars {
hash: hash.to_string(),
},
))
.await
.map(|x| x.get_package_release)
}
/// Retrieve all versions of a package as a stream that auto-paginates.
pub fn get_package_versions_stream(
client: &WasmerClient,