diff --git a/crates/torii/graphql/src/server.rs b/crates/torii/graphql/src/server.rs index 750aed70c0..eae85ba949 100644 --- a/crates/torii/graphql/src/server.rs +++ b/crates/torii/graphql/src/server.rs @@ -5,39 +5,26 @@ use async_graphql::dynamic::Schema; use async_graphql::http::GraphiQLSource; use async_graphql::Request; use async_graphql_warp::graphql_subscription; -use serde_json::json; use sqlx::{Pool, Sqlite}; use tokio::sync::broadcast::Receiver; use warp::{Filter, Rejection, Reply}; use super::schema::build_schema; -use crate::constants::MODEL_TABLE; -use crate::query::data::count_rows; pub async fn new( mut shutdown_rx: Receiver<()>, pool: &Pool, ) -> (SocketAddr, impl Future + 'static) { let schema = build_schema(pool).await.unwrap(); - let mut conn = pool.acquire().await.unwrap(); - let num_models = count_rows(&mut conn, MODEL_TABLE, &None, &None).await.unwrap(); - - let routes = graphql_filter(schema, num_models == 0); + let routes = graphql_filter(schema); warp::serve(routes).bind_with_graceful_shutdown(([127, 0, 0, 1], 0), async move { shutdown_rx.recv().await.ok(); }) } -fn graphql_filter( - schema: Schema, - is_empty: bool, -) -> impl Filter + Clone { +fn graphql_filter(schema: Schema) -> impl Filter + Clone { let graphql_post = async_graphql_warp::graphql(schema.clone()).and_then( move |(schema, request): (Schema, Request)| async move { - if is_empty { - return Ok::<_, Rejection>(empty_response()); - } - // Execute query let response = schema.execute(request).await; // Return result @@ -57,12 +44,3 @@ fn graphql_filter( graphql_subscription(schema).or(graphql_post).or(playground_filter) } - -fn empty_response() -> warp::reply::Json { - let empty_response = json!({ - "errors": [{ - "message": "World does not have any indexed data yet." - }] - }); - warp::reply::json(&empty_response) -}