Crates.io | mizuki |
lib.rs | mizuki |
version | 0.2.0 |
source | src |
created_at | 2023-12-04 09:48:25.871048 |
updated_at | 2024-03-06 07:35:56.267799 |
description | A toolkit for building Tauri Plugins that enables type-safe IPC through GraphQL. |
homepage | |
repository | https://github.com/tonymushah/mizuki |
max_upload_size | |
id | 1057485 |
size | 321,448 |
A toolkit for building Tauri plugins that enables type-safe IPC through GraphQL.
This project is a fork from JonasKruckenberg/tauri-plugin-graphql.
But I thought that it would be a great a idea to push the plugin futher and create a toolkit for building GraphQL Tauri Plugins.
[dependencies]
mizuki = "0.2.0"
The only client-side adapter currently is @mizuki/urql
, a custom exchange for urql
.
If you need adapters for other GraphQL clients, open a PR!
Package | Version (click for changelogs) |
---|---|
mizuki-urql-adapter |
You need to register the plugin giving it a async_graphql::Schema
. This schema will be used to fulfill requests.
use async_graphql::{Schema, Object, EmptySubscription, EmptyMutation, Result as GraphQLResult, SimpleObject};
#[derive(SimpleObject, Debug, Clone)]
struct ListItem {
id: i32,
text: String
}
impl ListItem {
pub fn new(text: String) -> Self {
Self {
id: rand::random::<i32>(),
text
}
}
}
struct Query;
#[Object]
impl Query {
async fn list(&self) -> GraphQLResult<Vec<ListItem>> {
let item = vec![
ListItem::new("foo".to_string()),
ListItem::new("bar".to_string())
];
Ok(item)
}
}
fn init_plugin<R: tauri::Runtime>() -> mizuki::MizukiPlugin<R, Query, EmptyMutation, EmptySubscription> {
mizuki::Builder::new("todo-plugin", Schema::new(
Query,
EmptyMutation,
EmptySubscription,
)).build()
}
fn main() {
tauri::Builder::default()
// The plugin name is required
.plugin(init_plugin())
.run(tauri::generate_context!())
.expect("failed to run app");
}
If you want to help out, there are a few areas that need improvement:
PRs are welcome!