linear-api 0.1.0

Unofficial async Rust client for the Linear GraphQL API (API-key auth)
Documentation
//! The crate's schema-drift tripwire: every GraphQL document this crate
//! ships must validate against the committed Linear SDL snapshot. This test
//! MUST stay a required CI check.

#[test]
fn all_documents_validate_against_committed_sdl() {
    let sdl = include_str!("../schema/linear.graphql");

    // Prefer a fully validated schema; if apollo's *schema* validation ever
    // rejects Linear's SDL, fall back to parse + assume-valid — the
    // protection that matters is EXECUTABLE document validation below.
    let schema = match apollo_compiler::Schema::parse_and_validate(sdl, "linear.graphql") {
        Ok(valid) => valid,
        Err(with_errors) => {
            eprintln!(
                "note: Linear SDL failed full schema validation; \
                 continuing with assume-valid:\n{}",
                with_errors.errors
            );
            apollo_compiler::validation::Valid::assume_valid(with_errors.partial)
        }
    };

    let mut failures = Vec::new();
    for (name, document) in linear_api::all_documents() {
        if let Err(err) = apollo_compiler::ExecutableDocument::parse_and_validate(
            &schema,
            document,
            format!("{name}.graphql"),
        ) {
            failures.push(format!("--- {name} ---\n{}", err.errors));
        }
    }
    assert!(
        failures.is_empty(),
        "GraphQL documents failed validation against schema/linear.graphql:\n{}",
        failures.join("\n")
    );
}