https://github.com/andriest/graphql-api
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.
https://github.com/andriest/graphql-api
crud-api diesel-cli graphql juniper rust rust-language-server
Last synced: about 1 month ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/andriest/graphql-api
- Owner: andriest
- Created: 2024-12-10T02:26:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-10T02:45:28.000Z (over 1 year ago)
- Last Synced: 2025-04-02T14:21:46.565Z (about 1 year ago)
- Topics: crud-api, diesel-cli, graphql, juniper, rust, rust-language-server
- Language: Rust
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-api
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.
## Features
- 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.
## Prerequisites
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)
## Installation
1. Setup the environment variables:
`cp .env.example .env`
env
`DATABASE_URL=postgres://username:password@localhost/graphql_db`
2. Run database migrations:
```
diesel setup
diesel migration run
```
3. Build and run the server:
`cargo run`
## Usage
Starting the Server
The server runs by default on http://127.0.0.1:8080/playground.
### Example Queries
#### Query Example
```
query {
getById(id: 1) {
id
nickname
}
}
```
#### Mutation Example
```
mutation {
updateAccount(id: 1, data: { nickname: "Updated Name" })
}
```
You can test these queries using tools like [Postman](https://www.postman.com/) or [GraphQL Playground](https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/).
## Technologies Used
- 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.
## Acknowledgments
- Juniper for enabling GraphQL in Rust.
- Diesel for powerful database management.
- Actix-Web for its high-performance server framework.