diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fbeeb88e9..c865b0976 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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 diff --git a/examples/axum-graphql_example/.gitignore b/examples/axum-graphql_example/.gitignore new file mode 100644 index 000000000..8503cc4cd --- /dev/null +++ b/examples/axum-graphql_example/.gitignore @@ -0,0 +1,3 @@ +db +db-shm +db-wal \ No newline at end of file diff --git a/examples/axum-graphql_example/README.md b/examples/axum-graphql_example/README.md new file mode 100644 index 000000000..9111c7cc1 --- /dev/null +++ b/examples/axum-graphql_example/README.md @@ -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 diff --git a/examples/axum-graphql_example/Screenshot1.png b/examples/axum-graphql_example/Screenshot1.png new file mode 100644 index 000000000..d2d81dbb2 Binary files /dev/null and b/examples/axum-graphql_example/Screenshot1.png differ diff --git a/examples/axum-graphql_example/Screenshot2.png b/examples/axum-graphql_example/Screenshot2.png new file mode 100644 index 000000000..171199c5b Binary files /dev/null and b/examples/axum-graphql_example/Screenshot2.png differ diff --git a/examples/axum-graphql_example/src/graphql/schema.rs b/examples/axum-graphql_example/src/graphql/schema.rs index 4cc356949..6224c409e 100644 --- a/examples/axum-graphql_example/src/graphql/schema.rs +++ b/examples/axum-graphql_example/src/graphql/schema.rs @@ -1,5 +1,6 @@ use async_graphql::{EmptySubscription, Schema}; use entity::async_graphql; +use migration::{Migrator, MigratorTrait}; use crate::{ db::Database, @@ -12,6 +13,8 @@ pub type AppSchema = Schema; 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()