This crate allows you to statically generate all files needed to use artemis.
While you could write these by hand, they're quite complex and hand-writing can easily introduce
errors, so this module allows you to instead have them generated automatically from
files. All you need apart from the files is an introspected schema in JSON or
or alternatively a server that has introspection enabled. Note that the second option requires
introspect feature to be enabled.
use artemis_build::CodegenBuilder; CodegenBuilder::new() .introspect_schema("http://localhost:8080/graphql", None, Vec::new()) .unwrap() .add_query("my_query.graphql") .with_out_dir("src/queries") .build();
The only required option is the schema - in this case we're introspecting one from
http://localhost:8080/graphql, with no authorization header and no extra headers - but if
you don't call
add_query at least once the code generator won't do much. The out dir specifies
the directory to output your query module to. It will generate a
mod.rs in this directory,
along with a file for each query and a global query enum for WASM support. Make sure this
directory doesn't already have a
mod.rs or it will be overridden.
The output directory defaults to
OUT_DIR, but for good autocomplete I recommend putting the
files somewhere in
src where your IDE picks them up.
For more information see each function definition.
Configuration object for code generation
An error that occurred in the build function