A template for creating services in Rust using Axum and Prisma.

Overview

Rust + Axum + Prisma

A template for creating services in Rust using Axum and Prisma. This uses the super cool Prisma Rust Client.

Getting Started

You'll want to have cargo-watch installed for the best DX, however it isn't required.

cargo install cargo-watch

Then you can run the cargo-watch -x run command to watch for changes and automatically rebuild the project.

Prisma

To set up prisma, run:

cargo prisma generate # outputs client to src/prisma.rs
cargo prisma db push # outputs sqlite db to prisma/dev.db (specified in schema.prisma)
cargo seed # seeds the database with some data (unimplemented, create a seed based on your needs)

For more in-depth information about the prisma client, see the Prisma Client Rust Docs.

Run the Server

To run the server, run:

cargo run # or cargo-watch -x run

GraphQL Playground

Go to localhost:8080/api/graphql to see the playground. You can see the schema and the docs, but a few examples would be:

# Create user
mutation {
  createUser(input: { displayName: "oromei" }) {
    id
  }
}

# Create post
mutation {
  createPost(
    input: {
      content: "Woah there!"
      userId: "5ab80953-c38c-4ec8-8b4b-3ecc4bc1196f"
    }
  ) {
    id
    content
    user {
      displayName
    }
  }
}

# Get all users
query {
  getUsers {
    id
    displayName
  }
}

# Get all posts
query {
  getPosts {
    id
    content
    user {
      displayName
    }
  }
}

Notes

This template uses Axum, but the bulk of the setup is for async_graphql + prisma. You should be able to easily swap out Axum for your preferred framework (e.g. Rocket, actix, etc).

The simple use of async_graphql means that queries are done in a less efficient manner than could be, since fetching relations using with is never utilized and relations are loaded separately. Additionally, dataloader is not utilized because I can't be bothered.

You might also like...
✨ A perfect template for a binary rust project.

Rust Template A project template for Rust, helping to structure your projects blazingly fast ⚡ . Features 🔥 Code-ready for binary projects. Add amazi

Compiler for Jade-like template language to cito.js-based virtual dom

Marafet A very experimental DSL for creating (mostly) single page applications in HTML. It's mostly a Jade-like (or Haml-like) templating language wit

A nice template for NEAR repos

Template for a NEAR project If you're looking for a no-std version of this template, go here. Contains: a setup script Cargo.toml setup with simulatio

Yew Tauri Desktop App Template

Yew Tauri Desktop App Template This is Template App for Desktop App. Run Develop $ cargo tauri dev Build App $ cargo tauri build Setup yew setup Using

Template for Cargo based SysY compiler projects.

基于 Cargo 的 SysY 编译器项目模板 该仓库中存放了一个基于 Cargo 的 SysY 编译器项目的模板, 你可以在该模板的基础上进行进一步的开发. 该仓库中的 Rust 代码实现仅作为演示, 不代表你的编译器必须以此方式实现. 如你需要使用该模板, 建议你删掉所有 Rust 源文件, 仅

Balsa is a delightfully simple HTML template engine

🌳 balsa Balsa is a delightfully simple HTML template engine. It is designed to be used in user interfaces such as a CMS where a user needs to be able

Bevy GitHub CI Template

Bevy GitHub CI Template This repo show how to setup CI on a github project for Bevy. It creates two workflows: CI Release CI Definition: .github/workf

Easily embed and manage assets for your web application to build standalone-executables. Offers filename hashing, templating and more.

reinda: easily embed and manage assets This library helps you manage your assets (external files) and is mostly intended to be used in web application

Automatic HTTPS certificates for Tide, via Let's Encrypt and ACME tls-alpn-01 challenges

tide-acme helps you serve HTTPS with Rust and Tide using automatic certificates, via Let's Encrypt and ACME tls-alpn-01 challenges. Documentation To u

Owner
Aaron Leopold
fullstack software dev | rust enthusiast 🦀 | likes espresso a little too much
Aaron Leopold
Templates for creating rust projects with a GitHub-managed lifecycle with cargo-generate 🏗️📃

rust-templates Templates for creating rust projects with a GitHub-managed lifecycle with cargo-generate. ??️ ?? What you get: PR build validation usin

Ben Greenier 1 Oct 30, 2021
Make creating nix expressions easy

Make creating nix expressions easy

Jonathan Ringer 186 Dec 21, 2022
finch - a super fast and efficient template rendering engine for node.js

finch A super fast and efficient template rendering engine for node.js, inspired by Handlebars. Usage Finch is very simple to use: Register a template

null 1 Nov 2, 2021
Yarte stands for Yet Another Rust Template Engine

Should we start to worry? bytes-buf feature can produce SIGILL. avx and sse flags are in almost all cpus of x86 and x86_64 architectures. More details

Juan Aguilar 249 Dec 19, 2022
A template engine for Rust based on Jinja2/Django

Tera Tera is a template engine inspired by Jinja2 and the Django template language. <title>{% block title %}{% endblock title %}</title> <ul> {% for u

Vincent Prouillet 2.5k Jan 1, 2023
A flexible template engine for Rust

Rustache Rustache is a Rust implementation of the Mustache spec. Documentation The different Mustache tags are documented at the mustache(5) man page.

rustache 208 May 10, 2022
A minimalist Rust WebAssembly project template

MiniWASM - A minimalist Rust WebAssembly project template This is a minimal Rust-powered WebAssembly application template. It was designed to showcase

Emil Loer 160 Jul 26, 2022
A template for a Rust-powered static-page Try Online interface

rust-tio-template A template for a Rust-powered static-page Try Online interface What is included This is an example setup that enables all of the fol

null 2 Dec 13, 2021
MiniJinja is a powerful but minimal dependency template engine for Rust

MiniJinja: a powerful template engine for Rust with minimal dependencies MiniJinja is a powerful but minimal dependency template engine for Rust which

Armin Ronacher 686 Jan 5, 2023
A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.

Rust on ESP-IDF "Hello, World" template A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework. This is the crate you get when ru

Ivan Markov 140 Jan 4, 2023