| 15 | |
| 16 | #[tokio::main] |
| 17 | async fn main() { |
| 18 | dotenv().ok(); |
| 19 | tracing_subscriber::fmt() |
| 20 | .with_max_level(tracing::Level::INFO) |
| 21 | .with_test_writer() |
| 22 | .init(); |
| 23 | let database = Database::connect(&*DATABASE_URL) |
| 24 | .await |
| 25 | .expect("Fail to initialize database connection"); |
| 26 | let schema = |
| 27 | sea_orm_seaography_example::query_root::schema(database, *DEPTH_LIMIT, *COMPLEXITY_LIMIT) |
| 28 | .unwrap(); |
| 29 | let app = Route::new().at( |
| 30 | &*ENDPOINT, |
| 31 | get(graphql_playground).post(GraphQL::new(schema)), |
| 32 | ); |
| 33 | println!("Visit GraphQL Playground at http://{}", *URL); |
| 34 | Server::new(TcpListener::bind(&*URL)) |
| 35 | .run(app) |
| 36 | .await |
| 37 | .expect("Fail to start web server"); |
| 38 | } |