Umbral
Back to plugin directory
UG

Umbral GraphQL

Official Featured by Umbral contributors

schema from your models, relations, mutations, subscriptions

official beta

About

A REST endpoint returns the shape you designed. A GraphQL endpoint returns the shape the caller designed — which is the whole appeal, and the reason this plugin makes you say yes on purpose. Point it at the models you already declared and it derives the schema: queries, relation traversal, mutations, and live subscriptions, with no resolver code to write and nothing to keep in sync by hand.

Install

cargo add umbral-graphql

Wire it up

use umbral::prelude::*;
use umbral_graphql::GraphqlPlugin;

let app = App::builder()
    .database("default", pool)
    .plugin(
        GraphqlPlugin::new()
            .expose("post")
            .expose("auth_user")
            .hide("auth_user", "email")   // exposing a model exposes EVERY column
            .mutable("post"),             // createPost / updatePost / deletePost
    )
    .build()?;
{ post(id: "1") { title author { username } comments { body } } }

Target: nothing leaves the database by accident

Exposing a model exposes every column on it, so reads and writes are separate opt-ins: expose makes a model readable, mutable makes it writable, subscribable makes it live. A read you got wrong leaks data; a write you got wrong destroys it.

A #[umbral(private)] column stays invisible until allow_private_if unlocks it for a caller who has earned it — and the schema stays one honest document, with the field always present and always nullable, because a caller without the unlock has to legally receive nothing.

What you get

  • Schema derived from the model registry — queries, filters, and relations
  • Mutations and live subscriptions, each a separate opt-in
  • Relation fields batched through a per-request DataLoader, so no N+1
  • #[umbral(private)] columns unlockable per caller, with one honest schema
  • Unauthorized writes refused by name, not silently dropped
  • GraphiQL explorer in dev

Usage

Nothing is exposed until you call `.expose("table")`, and an exposed model is readable but not writable until you also call `.mutable("table")`. Exposing a model exposes every column on it — reach for `.hide(..)` or `#[umbral(private)]` for anything that shouldn't leave the database.

plugin setup
cargo add umbral-graphql

Feature tracker

Per-feature shipping status, recorded in the directory.

8 of 8 shipped
Schema from the model registry shipped Beta

Queries, filters, and types derived from models you already declared.

Relation traversal shipped Beta

Walk FK, O2O, and M2M edges in one query, as deep as the caller asks.

DataLoader batching shipped Beta

Relation fields batch per request, so nested selections don't N+1.

Mutations shipped Beta

create / update / delete per model — a second opt-in on top of expose.

Subscriptions shipped Beta

Live per-model change streams over WebSocket, opt-in per model.

Private-column unlock shipped Beta

allow_private_if reveals a private column per caller, one honest schema.

Field hiding shipped Beta

hide drops columns from the schema — exposing a model exposes every column.

GraphiQL explorer shipped Beta

In-browser query console, toggleable for production.

Compatibility

Declared support per Umbral version and database backend.

No compatibility rows declared yet.

Community notes

0 notes in the discussion thread.

No notes yet. Be the first to share how this plugin works for you.

Reported issues

Bugs and abuse reports filed against this plugin.

Report an issue

No open issues

No issues have been reported against this plugin. Track upstream bugs on the maintainer's tracker, or report a directory problem to the Umbral team.