WIP subscription support, will require switching webserver

This commit is contained in:
2025-03-08 07:51:36 -08:00
parent 638d55a36c
commit d7217d1b3c
2 changed files with 20 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ use letterbox_server::tantivy::TantivyConnection;
use letterbox_server::{
config::Config,
error::ServerError,
graphql::{Attachment, GraphqlSchema, Mutation, QueryRoot},
graphql::{Attachment, GraphqlSchema, Mutation, QueryRoot, Subscription},
nm::{attachment_bytes, cid_attachment_bytes},
};
use rocket::{
@@ -159,7 +159,12 @@ async fn original(
#[rocket::get("/")]
fn graphiql() -> content::RawHtml<String> {
content::RawHtml(GraphiQLSource::build().endpoint("/api/graphql").finish())
content::RawHtml(
GraphiQLSource::build()
.endpoint("/api/graphql")
.subscription_endpoint("/api/graphql")
.finish(),
)
}
#[rocket::get("/graphql?<query..>")]
@@ -222,7 +227,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let tantivy_conn = TantivyConnection::new(&config.newsreader_tantivy_db_path)?;
let cacher = FilesystemCacher::new(&config.slurp_cache_path)?;
let schema = Schema::build(QueryRoot, Mutation, EmptySubscription)
let schema = Schema::build(QueryRoot, Mutation, Subscription)
.data(Notmuch::default())
.data(cacher)
.data(pool.clone());