use lazy_static::lazy_static; use std::path::Path; pub mod mutations; pub mod queries; lazy_static! { pub static ref URL: String = Path::new(&web_sys::window().unwrap().location().origin().unwrap()) .join("graphql") .to_str() .unwrap() .to_string(); } pub fn client(token: Option<&String>) -> Result { if let Some(x) = token { let mut headers = reqwest::header::HeaderMap::new(); headers.insert( "Authorization", reqwest::header::HeaderValue::from_str(&format!("Bearer {}", x)).unwrap(), ); reqwest::Client::builder().default_headers(headers).build() } else { Ok(reqwest::Client::new()) } }