trustfall-v0.5.0
版本发布时间: 2023-05-30 12:04:52
obi1kenobi/trustfall最新发布版本:trustfall-v0.7.1(2023-11-18 05:35:14)
What's Changed
-
Breaking:
execute_query()
now takesArc<impl Adapter>
instead ofRc<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 https://github.com/obi1kenobi/trustfall/pull/275 -
FilterTypeError
should display the inner error's message. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/278 - Update npm and Rust dependency versions. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/279
- Actually put url property on all webpage objects by @u9g in https://github.com/obi1kenobi/trustfall/pull/280
- Move test-related bin functionality out of
trustfall_core
. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/284 - Add helper for resolving coercions based on typename and schema. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/283
- Use
Arc
of adapter to execute queries. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/286 - Ensure we always output the inner error message. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/289
- Clearer error message. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/291
- Add Schema.subtypes to t-wasm by @u9g in https://github.com/obi1kenobi/trustfall/pull/292
- Broaden lifetimes in Hackernews example by @benwis in https://github.com/obi1kenobi/trustfall/pull/293
- Enable trusted publishing for Python packages. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/294
- Release v0.5.0 with
Arc
-based query execution. by @obi1kenobi in https://github.com/obi1kenobi/trustfall/pull/295
New Contributors
- @u9g made their first contribution in https://github.com/obi1kenobi/trustfall/pull/280
- @benwis made their first contribution in https://github.com/obi1kenobi/trustfall/pull/293
Full Changelog: https://github.com/obi1kenobi/trustfall/compare/trustfall-v0.4.0...trustfall-v0.5.0