use async_graphql::{Context, EmptySubscription, Object, Result, Schema};
use async_std::sync::RwLock;
use serde_json;
#[derive(Clone)]
struct Table {
name: String,
}
impl Table {
async fn new(name: String) -> Self {
Self { name: name }
}
}
#[Object]
impl Table {
async fn name(&self) -> String {
self.name.to_string()
}
}
struct Query;
#[Object]
impl Query {
async fn pointless(&self) -> String {
"this is pointless.".to_string()
}
async fn tables(&self, ctx: &Context<'_>) -> Vec
{
ctx.data::>>()
.unwrap()
.read()
.await
.to_vec()
}
}
struct Mutation;
#[Object]
impl Mutation {
async fn create_table(&self, ctx: &Context<'_>, name: String) -> Result