mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-09 11:21:51 +01:00
feat: fix extract
This commit is contained in:
parent
ab6141ffb4
commit
6d053da9f4
@ -278,10 +278,8 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let graphql_client = rust::import("crate::client", "graphql_client");
|
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
query.execute(&$graphql_client(&self.conn)).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::future::Future;
|
|
||||||
use std::pin::Pin;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
use base64::engine::general_purpose;
|
use base64::engine::general_purpose;
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use gql_client::ClientConfig;
|
use gql_client::ClientConfig;
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
use crate::connect_params::ConnectParams;
|
use crate::connect_params::ConnectParams;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
pub trait GraphQLClient {
|
pub trait GraphQLClient {
|
||||||
fn query<K>(&self, query: String) -> Pin<Box<dyn Future<Output = eyre::Result<Option<K>>>>>
|
async fn query(&self, query: &str) -> eyre::Result<Option<serde_json::Value>>;
|
||||||
where
|
|
||||||
K: for<'de> Deserialize<'de>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type DynGraphQLClient = Arc<dyn GraphQLClient + Send + Sync>;
|
pub type DynGraphQLClient = Arc<dyn GraphQLClient + Send + Sync>;
|
||||||
@ -41,14 +38,15 @@ impl DefaultGraphQLClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
impl GraphQLClient for DefaultGraphQLClient {
|
impl GraphQLClient for DefaultGraphQLClient {
|
||||||
fn query<K>(&self, query: String) -> Pin<Box<dyn Future<Output = eyre::Result<Option<K>>>>>
|
async fn query(&self, query: &str) -> eyre::Result<Option<serde_json::Value>> {
|
||||||
where
|
let res: Option<serde_json::Value> = self
|
||||||
Self: Sized,
|
.client
|
||||||
K: for<'de> Deserialize<'de>,
|
.query(&query)
|
||||||
{
|
.await
|
||||||
let res = self.client.query::<K>(&query);
|
.map_err(|r| eyre::anyhow!(r.to_string()))?;
|
||||||
|
|
||||||
return Box::pin(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user