Skip to main content

If GraphQL were more like SQL: a query language for any combination of data sources.

Project description

trustfall — Python bindings

Use the Trustfall query engine from Python.

API

Create a schema object:

from trustfall import Schema

my_schema = Schema(
    """
    Your schema text here, written in GraphQL SDL.

    See an example schema here:
    https://github.com/obi1kenobi/trustfall/blob/main/pytrustfall/numbers.graphql
    """
)

Create an adapter with which to query the schema:

from typing import Any, Dict

from trustfall import Adapter

# Choose the type that is used to represent data vertices:
Vertex = Dict[str, Any]

class MyAdapter(Adapter[Vertex]):
    # Implement the four abstract methods from Adapter.
    ...

Execute queries:

from trustfall import execute_query

my_adapter = MyAdapter(...)

my_query = """
query {
    # your query here
}
"""
args = {
    # query arguments here
}

results_iterator = execute_query(
    my_adapter,
    my_schema,
    my_query,
    args,
)
for result in results_iterator:
    print(result)

Installing trustfall

This package is a wrapper around the Trustfall query engine, which is written in Rust.

Wheels are available for Windows, macOS (both x86 and ARM), and Linux (manylinux), for each supported version of CPython (3.9+).

This package should work on other platforms as well, in which case its Rust components may need to be compiled from source as part of the installation process.

If you get errors while installing this package, please report your OS and architecture info in an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trustfall-0.1.6.tar.gz (254.9 kB view hashes)

Uploaded Source

Built Distributions

trustfall-0.1.6-cp311-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

trustfall-0.1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

trustfall-0.1.6-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.5 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

trustfall-0.1.6-cp311-cp311-macosx_10_7_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

trustfall-0.1.6-cp310-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

trustfall-0.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

trustfall-0.1.6-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.5 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

trustfall-0.1.6-cp310-cp310-macosx_10_7_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

trustfall-0.1.6-cp39-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

trustfall-0.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

trustfall-0.1.6-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

trustfall-0.1.6-cp39-cp39-macosx_10_7_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page