mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-04 06:43:26 +02:00
with session
This commit is contained in:
34
src/session.rs
Normal file
34
src/session.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use graphql_client::reqwest::post_graphql_blocking;
|
||||
use graphql_introspection_query::introspection_response::IntrospectionResponse;
|
||||
use reqwest::blocking::Client;
|
||||
|
||||
use crate::{config::Config, connect_params::ConnectParams};
|
||||
|
||||
pub struct Session {}
|
||||
|
||||
impl Session {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
||||
pub fn start(&self, cfg: Config, conn: &ConnectParams) -> eyre::Result<Client> {
|
||||
let client = Client::builder()
|
||||
.user_agent("graphql-rust/0.10.0")
|
||||
.default_headers(
|
||||
std::iter::once((
|
||||
reqwest::header::AUTHORIZATION,
|
||||
reqwest::header::HeaderValue::from_str(&format!(
|
||||
"Bearer {}",
|
||||
conn.session_token
|
||||
))
|
||||
.unwrap(),
|
||||
))
|
||||
.collect(),
|
||||
)
|
||||
.build()?;
|
||||
|
||||
let schema = post_graphql_blocking::<IntrospectionResponse, _>(&client, conn.url(), vec![]);
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user