move code to dagger-core

This commit is contained in:
2023-02-05 22:26:58 +01:00
parent 9f0021b708
commit ec0d0b22e6
18 changed files with 132 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
use std::{collections::HashMap, ops::Add, sync::Arc};
use serde::Serialize;
use futures::executor::block_on;
use serde::{Deserialize, Serialize};
pub fn query() -> Selection {
Selection::default()
@@ -92,6 +93,20 @@ impl Selection {
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
}
pub fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<Option<D>>
where
D: for<'de> Deserialize<'de>,
{
let query = self.build()?;
let resp: Option<D> = match block_on(gql_client.query(&query)) {
Ok(r) => r,
Err(e) => eyre::bail!(e),
};
Ok(resp)
}
fn path(&self) -> Vec<Selection> {
let mut selections: Vec<Selection> = vec![];
let mut cur = self;