Skip to content

Trustfall v0.5.0

Compare
Choose a tag to compare
@obi1kenobi obi1kenobi released this 30 May 04:04
· 337 commits to main since this release
94c6243

What's Changed

  • Breaking: execute_query() now takes Arc<impl Adapter> instead of Rc<impl Adapter> for consistency with other APIs and easier use in web servers: #286
  • New resolve_coercion_using_schema() helper method to simplify implementing adapters' resolve_coercion() method.
  • TryIntoStruct trait for ergonomic result parsing into a struct, for example:
use trustfall::TryIntoStruct;

// Define a struct whose field names and types match
// those returned by a query, and derive `serde::Deserialize` on it.
#[derive(Debug, PartialEq, Eq, serde::Deserialize)]
struct Output {
    number: i64,
    text: String,
}

// Elsewhere, we run a query that outputs a `number` integer
// and a `text` string field.
let query = r#"
{
    Query {
        number @output
        text @output
    }
}
"#;
let results: Vec<_> = execute_query(schema, adapter, query, variables)
    .expect("bad query arguments")
    .map(|v| v.try_into_struct().expect("struct definition did not match query result shape"))
    .collect();

// The `try_into_struct()` call turned the query results into `Output` structs.
assert_eq!(
    vec![
        Output {
            number: 42,
            text: "the answer to everything".to_string(),
        },
    ],
    results,
);

Migrating from Trustfall v0.4

Wrap your adapters in Arc instead of Rc before calling execute_query().

All Merged PRs

  • Add TryIntoStruct trait for ergonomic result parsing into a struct. by @obi1kenobi in #275
  • FilterTypeError should display the inner error's message. by @obi1kenobi in #278
  • Update npm and Rust dependency versions. by @obi1kenobi in #279
  • Actually put url property on all webpage objects by @u9g in #280
  • Move test-related bin functionality out of trustfall_core. by @obi1kenobi in #284
  • Add helper for resolving coercions based on typename and schema. by @obi1kenobi in #283
  • Use Arc of adapter to execute queries. by @obi1kenobi in #286
  • Ensure we always output the inner error message. by @obi1kenobi in #289
  • Clearer error message. by @obi1kenobi in #291
  • Add Schema.subtypes to t-wasm by @u9g in #292
  • Broaden lifetimes in Hackernews example by @benwis in #293
  • Enable trusted publishing for Python packages. by @obi1kenobi in #294
  • Release v0.5.0 with Arc-based query execution. by @obi1kenobi in #295

New Contributors

Full Changelog: trustfall-v0.4.0...trustfall-v0.5.0