[−][src]Struct artemis_build::CodegenBuilder
Configuration object for code generation
This is used to generate the query structs and modules that are required as well as TypeScript definitions and some static analysis info.
Methods
impl CodegenBuilder
[src]
pub fn new() -> Self
[src]
Create a new codegen builder with default configuration values.
Note that a schema must
be set, either by setting a file or introspecting it.
All other configuration is optional, though it won't do much if you don't add any queries.
pub fn add_query<T: AsRef<Path>>(self, query_path: T) -> Self
[src]
Add a query to have the code generator generate a module for it. This is currently opt-in for each file to prevent accidentally generating unneeded code, but a directory based approach may be added later.
pub fn with_derives_on_variables<T: Into<String>>(self, derives: T) -> Self
[src]
A comma-separated list of derives to add to the generated Variables
and input structs.
The default derives are Serialize
and Clone
, with Deserialize
added if the target
arch is wasm32
. Adding these here won't break anything, but it's redundant.
pub fn with_derives_on_response<T: Into<String>>(self, derives: T) -> Self
[src]
A comma-separated list of derives to add to the generated ResponseData
and output structs.
The default derives are Deserialize
and Clone
, with Serialize
added if the target
arch is wasm32
. Adding these here won't break anything, but it's redundant.
pub fn with_deprecation_strategy(self, strategy: DeprecationStrategy) -> Self
[src]
Set the deprecation strategy used for codegen. Can be used to either warn or completely fail the build if any of your GraphQL queries contain deprecated fields.
pub fn with_out_dir<T: AsRef<Path>>(self, out_dir: T) -> Self
[src]
Set the output directory for the query module. Defaults to OUT_DIR
, but it's recommended
to put this in an otherwise empty folder in src
.
pub fn with_schema<T: AsRef<Path>>(self, schema_path: T) -> Self
[src]
Sets the schema from a JSON or GraphQL file. The schema should be the result of an
introspection query done against the API you're generating code for.
If this isn't set, introspect_schema
must be used.
pub fn build(self) -> Result<(), BuildError>
[src]
Finish the configuration and generate the queries module.
It will generate a exchanges
and a file for each query in the selected output directory.
It's recommended for that to be an empty directory in src
.
This returns an error if an output directory was not set and OUT_DIR
could not be read,
a schema was not found or an error occurred during codegen or IO.
Trait Implementations
impl Debug for CodegenBuilder
[src]
impl Default for CodegenBuilder
[src]
fn default() -> CodegenBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for CodegenBuilder
impl Send for CodegenBuilder
impl Sync for CodegenBuilder
impl Unpin for CodegenBuilder
impl UnwindSafe for CodegenBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,