Skip to main content

Crate necrassrs_build

Crate necrassrs_build 

Source
Expand description

SDL validation, Rust generation, and resolver synchronization for Cargo builds.

Add this crate to your application’s build dependencies and call build from build.rs. No installed CLI or separate generation command is required.

§Build script

fn main() -> Result<(), necrassrs_build::BuildError> {
    necrassrs_build::build("schema")
}

Include the disposable output in your application’s src/generated.rs:

include!(concat!(env!("OUT_DIR"), "/necrassrs.rs"));

Declare mod generated; and mod resolvers; in the application root. Generated code refers to the application’s necrassrs runtime dependency. Contracts live in generated::resolvers, argument structs in generated::types::<Object>::<field>::Args, and execution wiring in generated::dispatch. The generated SDL constant contains the schema.

§Source ownership

Building modifies src/resolvers.rs. SDL owns resolver declarations; applications own retained resolver bodies and unrelated code. New fields get explicit unimplemented!() stubs. Deleted fields lose their resolver declarations and bodies. A rename is a deletion plus a new stub, without body migration. Review source changes after editing SDL. Retained bodies may need manual changes when arguments or result types change.

Generated contract types cover built-in scalars, enums, ordinary input objects, lists, nullable wrappers, owned Object results, and Interface and Union results. Query and mutation dispatch accept built-in scalar, enum, and ordinary input object arguments and support nullable/list forms, OneOf inputs, recursive input boxing, and recursive Object relationships. Custom scalars, borrowed Object results, and subscription roots are unsupported. Applications must configure panic = "abort" in their root dev and release profiles to enforce process termination on unimplemented calls. This affects all panics; ordinary application failures should be returned as runtime resolver errors.

Modules§

codegen
In-memory Rust generation from a validated Reed schema.

Enums§

BuildError
A failure while reading inputs, generating contracts, or synchronizing source.

Functions§

build
Generates OUT_DIR/necrassrs.rs from .graphql files recursively discovered under schema_dir, sorted by path. Symbolic-link entries are skipped. Creates and synchronizes editable query, mutation, and Object resolvers in src/resolvers.rs.