-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docs and README for
trustfall_stubgen
. (#334)
- Loading branch information
1 parent
5daac1f
commit aaac853
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 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 the 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](https://github.com/obi1kenobi/trustfall/tree/main/trustfall_stubgen/test_data/expected_outputs/hackernews/adapter) | ||
from this crate's test suite. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters