Function init_with_graphiql

Source
pub fn init_with_graphiql<R, Query, Mutation, Subscription>(
    schema: Schema<Query, Mutation, Subscription>,
    graphiql_addr: impl Into<SocketAddr>,
) -> TauriPlugin<R>
where R: Runtime, Query: ObjectType + 'static, Mutation: ObjectType + 'static, Subscription: SubscriptionType + 'static,
Expand description

Initializes the GraphQL plugin and GraphiQL IDE.

This plugin exposes a async-graphql endpoint via Tauri’s IPC system, allowing the frontend to invoke backend functionality through GraphQL. While the regular init function does not open a web server, the GraphiQL client is exposed over http.

The schema argument must be a valid async_graphql::Schema.

§Example

use async_graphql::{Schema, Object, EmptyMutation, EmptySubscription, SimpleObject, Result as GraphQLResult};

#[derive(SimpleObject)]
struct User {
    id: i32,
    name: String
}

struct Query;

// Implement resolvers for all possible queries.
#[Object]
impl Query {
    async fn me(&self) -> GraphQLResult<User> {
        Ok(User {
            id: 1,
            name: "Luke Skywalker".to_string(),
        })
    }
}

let schema = Schema::new(
    Query,
    EmptyMutation,
    EmptySubscription,
);

tauri::Builder::default()
    .plugin(tauri_plugin_graphql::init_with_graphiql(schema, ([127,0,0,1], 8080)));