trustfall

A query engine for any combination of data sources. Query your files and APIs as if they were databases!

APACHE-2.0 License

Downloads
848
Stars
2.3K
Committers
7

Bot releases are hidden (Show)

trustfall - trustfall-v0.7.1 Latest Release

Published by obi1kenobi 11 months ago

A major new update to the Adapter API in order to allow more flexibility when creating and composing adapters: #481

It requires tweaks to adapter implementations to make property and edge resolvers include the V: AsVertex<Self::Vertex> + 'a generic parameter. In practice, this change should be possible to do with only find-and-replace, since other helper functions like accessor_property!() or resolve_property_with() had their APIs updated to dereference via AsVertex as well. For example: https://github.com/obi1kenobi/trustfall-rustdoc-adapter/pull/305/files#diff-f6f5d3d9607240984eb0cbf4ebcf94307990abe1c5a2092756f48ef35798348f

Other Highlights

  • Query evaluation optimization: stop evaluating @fold early if it has no outputs and its count is never observed by the query: #423
  • Expand the adapter optimizations API with the ability to check which properties are used within a vertex: #449
  • accessor_property!() now has a form that allows specifying additional arguments for the function being called: https://github.com/obi1kenobi/trustfall/pull/513
  • Support repeatable on @filter directives by upgrading to a newer parser version.
  • Substantial expansion of the queryable surface area SchemaAdapter supports.
  • Changed representation of FieldValue to make it cheaper to clone, which our APIs will now do a bit more freely.

All Merged Commits

New Contributors

Full Changelog: https://github.com/obi1kenobi/trustfall/compare/trustfall-v0.6.1...trustfall-v0.7.1

trustfall - trustfall-v0.6.1

Published by obi1kenobi about 1 year ago

A maintenance release, upgrading trustfall_derive to syn v2 in an attempt to speed up compilation for our dependents by avoiding the use of multiple major versions of a large crate.

All Merged PRs

Full Changelog: https://github.com/obi1kenobi/trustfall/compare/trustfall-v0.6.0...trustfall-v0.6.1

trustfall - trustfall_stubgen-v0.3.0

Published by obi1kenobi about 1 year ago

What's Changed

  • Feature: Generate adapter test case using Trustfall's check_adapter_invariants() (#389)
  • Feature: Generate improved edge-handling code in trustfall_stubgen (#352)

All Merged PRs

Full Changelog: https://github.com/obi1kenobi/trustfall/compare/trustfall_stubgen-v0.2.2...trustfall_stubgen-v0.3.0

trustfall - trustfall-v0.6.0

Published by obi1kenobi about 1 year ago

What's Changed

  • Breaking: the FieldValue::DateTime variant has been removed since it used the unmaintained chrono library (#399)
  • Breaking: FieldValue::String and FieldValue::List now use Arc internally, making FieldValue cheap to clone (#400)
  • Feature: Automatic checker for ensuring Adapter implementations implement their schema and uphold invariants (#384)
  • Feature: TryIntoStruct can now also unpack EdgeParameters (#343)
  • Feature: when querying schemas using SchemaAdapter, it's now possible to query edge parameters' default values (#396)

Feature Highlight: Automatic tests for Adapter implementations (#384)

The new check_adapter_invariants() function is a self-contained adapter tester that can ensure you didn't forget to implement any components of your adapter's schema. Using it is as simple as:

pub use trustfall::provider::check_adapter_invariants;

#[test]
fn ensure_adapter_satisfies_invariants() {
    let adapter = todo!("get an `impl Adapter` type");
    let schema = todo!("get a `&Schema` for our adapter");
    check_adapter_invariants(schema, adapter);
}

In addition to catching incomplete schema implementation errors, it also catches violations of other Trustfall adapter invariants, such as context reordering or accidentally dropped data.

For more information, check out its docs: https://github.com/obi1kenobi/trustfall/blob/trustfall-v0.6.0/trustfall_core/src/interpreter/helpers/correctness.rs#L15-L78

Upgrading from Trustfall v0.5.x

The breaking changes should be immaterial to almost all users. Most use cases should be able to upgrade to Trustfall v0.6 without any changes to their own code.

All Merged PRs

Full Changelog: https://github.com/obi1kenobi/trustfall/compare/trustfall-v0.5.1...trustfall-v0.6.0

trustfall - trustfall_stubgen-v0.2.1

Published by obi1kenobi over 1 year ago

New crate: trustfall_stubgen

Given a Trustfall schema, autogenerate a high-quality Rust adapter stub fully wired up with all types, properties, and edges referenced in the schema.

First, install this crate's CLI with: cargo install --locked trustfall_stubgen --features cli

Then generate Trustfall adapter stubs for your schema with:

trustfall_stubgen --schema <your_schema.graphql> --target <output_directory>

Under the hood this directly calls the generate_rust_stub() function from this crate. This crate can also be used as a library, so you can call that function directly from your own code without going through the CLI.

The generated Trustfall adapter stub has the following structure:

file name purpose
adapter/mod.rs connects everything together
adapter/schema.graphql contains the schema for the adapter
adapter/adapter.rs contains the adapter implementation
adapter/vertex.rs contains the vertex type definition
adapter/entrypoints.rs contains the entry points where all queries must start
adapter/properties.rs contains the property implementations
adapter/edges.rs contains the edge implementations

See an example of a generated adapter stub from this crate's test suite.

trustfall - Trustfall v0.5.1

Published by obi1kenobi over 1 year ago

What's Changed

Added a SchemaAdapter that allows running Trustfall queries against Trustfall schemas, like so:

{
    VertexType {
        name @output

        edge {
            edge_name: name @output

            parameter_: parameter @fold {
                name @output
            }
        }
    }
}

For a given schema, running this query returns all edges on all vertex types, together with a list of the parameters those edges take.

All Merged PRs

New Contributors

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

trustfall - Trustfall v0.5.0

Published by obi1kenobi over 1 year ago

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

New Contributors

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

trustfall - Trustfall v0.4.0

Published by obi1kenobi over 1 year ago

What's Changed

  • Breaking: Adapter trait methods now take &self instead of &mut self to avoid reentrancy bugs: #249
  • Breaking: Released the new optimizations API: Adapter methods now take a resolve_info argument that can be used to get information about the query for the purpose of applying optimizations. In cargo-semver-checks this new API led to a 2354x speedup.
  • Many smaller bug fixes thanks to 26,000+ lines of new tests and test code.

Migrating from Trustfall v0.3

Replace all BasicAdapter and Adapter method receivers with &self instead of &mut self.

If you need mutability, you need to do BOTH of these things:

  • advance the ContextIterator input iterator before doing any mutation, to avoid reentrancy bugs
  • use RefCell around your Adapter or BasicAdapter's mutable state, making sure to not hold its mutable borrow across operations on the input ContextIterator in order to avoid reentrancy bugs

All Merged PRs

New Contributors

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

trustfall - pytrustfall v0.1.0 fb81f5b - Python query bindings

Published by obi1kenobi almost 3 years ago

Python bindings for the query engine, built from main branch commit fb81f5b.

Package Rankings
Top 7.06% on Crates.io
Top 18.06% on Pypi.org
Top 24.54% on Npmjs.org