graphql-api is a GraphQL API built with Rust using the juniper library. This project is designed to provide a robust and efficient GraphQL server with support for database integration via diesel.
- GraphQL API: Built using juniper for defining queries, mutations, and schema.
- Database Integration: Uses diesel as the ORM for database queries.
- Async Server: Powered by actix-web for efficient request handling.
To run this project, you’ll need the following installed:
- Rust (latest stable version)
- Diesel CLI (for managing database migrations)
- A database (e.g., PostgreSQL, SQLite, or MySQL)
-
Setup the environment variables:
cp .env.example .env
env
DATABASE_URL=postgres://username:password@localhost/graphql_db
-
Run database migrations:
diesel setup diesel migration run
-
Build and run the server:
cargo run
Starting the Server
The server runs by default on http://127.0.0.1:8080/playground.
query {
getById(id: 1) {
id
nickname
}
}
mutation {
updateAccount(id: 1, data: { nickname: "Updated Name" })
}
You can test these queries using tools like Postman or GraphQL Playground.
- Rust: High-performance systems programming language.
- Juniper: GraphQL library for Rust.
- Diesel: ORM for database queries and migrations.
- Actix-Web: Web framework for building the HTTP server.
- Juniper for enabling GraphQL in Rust.
- Diesel for powerful database management.
- Actix-Web for its high-performance server framework.