Skip to content

Commit

Permalink
Pr/587 (#1)
Browse files Browse the repository at this point in the history
* Migrate on startup

* Update CI

* Add .gitignore

* Add README

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
  • Loading branch information
aaronleopold and billy1624 authored Mar 8, 2022
1 parent 08423cb commit e07aa66
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
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

0 comments on commit e07aa66

Please sign in to comment.