MyGit

trustfall-v0.5.0

obi1kenobi/trustfall

版本发布时间: 2023-05-30 12:04:52

obi1kenobi/trustfall最新发布版本:trustfall-v0.7.1(2023-11-18 05:35:14)

What's Changed

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

New Contributors

Full Changelog: https://github.com/obi1kenobi/trustfall/compare/trustfall-v0.4.0...trustfall-v0.5.0

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-05-30发行的版本