Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/587 #1

Merged
merged 4 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
path: [basic, actix_example, actix4_example, axum_example, rocket_example, poem_example]
path: [basic, actix_example, actix4_example, axum_example, axum-graphql_example, rocket_example, poem_example]
steps:
- uses: actions/checkout@v2

Expand Down
3 changes: 3 additions & 0 deletions examples/axum-graphql_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
db
db-shm
db-wal
13 changes: 13 additions & 0 deletions examples/axum-graphql_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
![screenshot](Screenshot1.png)

![screenshot](Screenshot2.png)

# Axum-GraphQL with SeaORM example app

1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database

1. Turn on the appropriate database feature for your chosen db in `entity/Cargo.toml` (the `"sqlx-sqlite",` line)

1. Execute `cargo run` to start the server

1. Visit [localhost:3000/api/graphql](http://localhost:3000/api/graphql) in browser
Binary file added examples/axum-graphql_example/Screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/axum-graphql_example/Screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/axum-graphql_example/src/graphql/schema.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use async_graphql::{EmptySubscription, Schema};
use entity::async_graphql;
use migration::{Migrator, MigratorTrait};

use crate::{
db::Database,
Expand All @@ -12,6 +13,8 @@ pub type AppSchema = Schema<Query, Mutation, EmptySubscription>;
pub async fn build_schema() -> AppSchema {
let db = Database::new().await;

Migrator::up(db.get_connection(), None).await.unwrap();

Schema::build(Query::default(), Mutation::default(), EmptySubscription)
.data(db)
.finish()
Expand Down