INNER CODE UNIT · Rust

create_schema_with_context

rkudryashov/graphql-rust-demo · planets-service/src/lib.rs:62

pub fn create_schema_with_context(pool: PgPool) -> Schema<Query, Mutation, Subscription> {
    let arc_pool = Arc::new(pool);
    let cloned_pool = Arc::clone(&arc_pool);
    let details_data_loader =
        DataLoader::new(DetailsLoader { pool: cloned_pool }, actix_rt::spawn).max_batch_size(10);

    let kafka_consumer_counter = Mutex::new(0);

    Schema::build(Query, Mutation, Subscription)
        // limits are commented out, because otherwise introspection query won't work
        // .limit_depth(3)
        // .limit_complexity(15)
        .data(arc_pool)
        .data(details_data_loader)
        .data(kafka::create_producer())
        .data(kafka_consumer_counter)
        .enable_subscription_in_federation()
        .finish()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…