use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
pub const INTROSPECTION_QUERY: &str = include_str!("introspection_query.graphql");
pub const GRAPHQL_REQUEST: GraphqlRequest = GraphqlRequest {
query: INTROSPECTION_QUERY,
operation_name: "IntrospectionQuery",
};
#[derive(Debug, Serialize, Deserialize)]
pub struct GraphqlRequest {
pub query: &'static str,
pub operation_name: &'static str,
}
#[async_trait(?Send)]
pub trait Runtime {
type Error: ToString;
async fn date(&self) -> Result<String, Self::Error>;
async fn get_args(&self) -> Result<Vec<String>, Self::Error>;
async fn query(
&self,
url: &str,
graphql: &GraphqlRequest,
headers: HashMap<String, String>,
) -> Result<Value, Self::Error>;
async fn read_file(&self, path: &str) -> Result<String, Self::Error>;
async fn prepare_output_directory(&self, output: &str) -> Result<(), Self::Error>;
async fn write_file(&self, output: &str, file: &str, contents: &str)
-> Result<(), Self::Error>;
}