async-graphql
async-graphql copied to clipboard
Is there a void return type for async graphql mutation?
My issue is that I want to return an empty tuple wrapped in a Result for a delete mutation. However, Rust panics that:
the trait bound (): async_graphql::OutputType is not satisfied
the following other types implement trait async_graphql::OutputType
Right now I am forced to have to return a &str wrapped inside a Result.
In essence, is there a void return type for async graphql?
#[Object]
impl MutationResolver {
async fn delete_books(
&self,
ctx: &Context<'_>,
table: String,
delete_records: Vec<BookRecordInput>,
) -> Result<()> {
let data_store = ctx.data_unchecked::<Datastore>();
let res = delete_books(data_store, table, delete_records)
.await
.unwrap();
// Ok("Delete")
Ok(())
}
}
The Void type is not defined in the GraphQL specification, so you must return a value. 🙂
I'm a noob here, but couldn't you make it a Option<String> and return None?
If that doesn't work, you could just return the number of books deleted.