use crate::data::*;
use entity::Id;
use log::trace;
pub struct Mutation;
#[async_graphql::Object]
impl Mutation {
async fn import_wiki(
&self,
path: String,
index: u32,
name: Option<String>,
#[graphql(default = "wiki")] ext: String,
) -> async_graphql::Result<Wiki> {
trace!(
"import_wiki(path: {:?}, index: {}, name: {:?})",
path,
index,
name
);
Wiki::load(
index as usize,
path,
name,
ext.as_str(),
|_| {},
|_, _, _| {},
|_| {},
)
.await
}
async fn import_file(
&self,
wiki: Option<Id>,
path: String,
) -> async_graphql::Result<ParsedFile> {
trace!("import_file(path: {:?})", path);
ParsedFile::load(wiki, path).await
}
async fn create_file(
&self,
wiki: Option<Id>,
path: String,
contents: String,
#[graphql(default)] overwrite: bool,
) -> async_graphql::Result<ParsedFile> {
trace!(
"create_file(path: {:?}, contents: {:?}, overwrite: {})",
path,
contents,
overwrite
);
ParsedFile::create(wiki, path, contents, overwrite).await
}
}