Crate graphql_operation_server_harness

Crate graphql_operation_server_harness 

Source
Expand description

GraphQL Operation Server Harness

A test harness for mocking GraphQL endpoints with predefined responses.

§Example

use graphql_operation_server_harness::prelude::*;

#[tokio::main]
async fn main() -> Result<(), HarnessError> {
    let result = ScenarioBuilder::new()
        .server(AsyncGraphQL::default())
        .collector(DefaultCollector::new())
        .operation(
            Operation::query()
                .with_field(
                    Field::new("users")
                        .with_handler(Handler::new(serde_json::json!({
                            "users": [{"id": 1, "name": "John"}]
                        })))
                )
        )
        .build()
        .execute()
        .await?;

    Ok(())
}

Re-exports§

pub use error::HarnessError;

Modules§

entities
error
prelude
Prelude module for convenient imports
use_cases

Structs§

AsyncGraphQL
AsyncGraphQL-compatible server implementation
DefaultCollector
Default collector implementation using a thread-safe vector