Anyone worked with the async graphql crate here?
I have a create_book
function as part of my MutationResolver that receives the graphql async Context
type in order to pull out the Datastore struct.
use async_graphql::{Context, Object, Result, ID};
async fn create_book(
&self,
ctx: &Context<'_>,
table: String,
name: String,
author: String,
) -> Result<Book> {
let data_store = ctx.data_unchecked::<Datastore>();
let res = create_book(data_store, table, name, author).await.unwrap();
Ok(res)
}
//Test
//ERROR MESSAGE with Context below: expected value, found type alias `Context`
//can't use a type alias as a constructor
#[tokio::test]
async fn test_01_try_create_book() {
let table = "users".to_string();
let name = "HP".to_string();
let author = "JKR".to_string();
let test = MutationResolver
.create_book(&Context, table, name, author)
.await
.unwrap();
}
How come my test is complaining that it can't take Context as a param but no corresponding issues with the create_book function taking the Context type?