Skip to main content

Crate necrassrs

Crate necrassrs 

Source
Expand description

GraphQL request execution for SDL-first Rust applications.

NecrassRs separates build-time contracts from runtime execution. The necrassrs-build crate generates resolver traits, argument types, and a dispatcher from SDL. Applications implement resolver bodies, own their Context type, and pass a Context value to execute for each request. HTTP integration is provided separately by necrassrs-axum.

§Request flow

  1. Parse your schema with Schema::parse_and_validate, usually once at startup.
  2. Construct a Request with a document and optional variables/operation name.
  3. Call execute with the schema, dispatcher, and request Context.
  4. Serialize the returned Response or pass it to the HTTP adapter.

Request validation errors omit data. Resolver failures become GraphQL execution errors with a field path and source location; nullability determines whether other data can be returned. Return ResolverError for application failures. Panics are not converted into GraphQL errors.

§Current scope

Generated query, mutation, and subscription contracts support built-in and custom scalars, enum results, ordinary and OneOf input objects, nullable/list forms, recursive input boxing, owned Object results, and abstract results. The runtime preserves Object parents, list-item conversion errors, and nullability during completion. Borrowed Object results remain unsupported. Schema introspection is enabled by default; use execute_with_options to disable it independently of any UI.

Structs§

ExecutionOptions
Server-controlled execution settings.
FieldCoordinate
Original SDL coordinates of a field to resolve, independent of query aliases.
GraphQLError
A serializable error, as found in a GraphQL response.
Id
A GraphQL ID that preserves its supplied string representation.
Request
An owned GraphQL document, optional operation name, and variable values.
ResolverError
An application failure returned by a resolver.
Response
A serializable GraphQL request-error or execution response.
ResponseStream
Ordered GraphQL response events from a subscription.
Schema
High-level representation of a GraphQL type system document a.k.a. schema.
SourceStream
A subscription source stream.
Valid
Wraps a Schema or [ExecutableDocument] to mark it as valid.

Enums§

GraphQLInput
The presence state of a nullable GraphQL argument or input object field.
ResolvedValue
A resolved value tree retaining Object parents and conversion errors.
ScalarLiteral
Executable AST for a literal GraphQL Value.
SourceEvent
One item produced by a subscription source.
SubscriptionError
A terminal failure of a subscription response stream.

Traits§

Dispatcher
Connects execution to application resolvers for Context type C.
Field
Identifies one generated GraphQL field and its argument type.
ResolvedObject
A resolved Object value that dispatches fields against its parent instance.
Resolver
Resolves a generated GraphQL field against an application-owned parent value.
Scalar
Converts values between GraphQL inputs, an application-owned scalar, and JSON output.
Subscriber
Creates a source stream for a generated subscription root field.

Functions§

execute
Validates and executes a request with introspection enabled.
execute_with_options
Executes a request with server-owned settings.
subscribe
Validates a subscription request and creates its source stream.
subscribe_with_options
Validates a subscription request and creates its source stream with server settings.

Type Aliases§

JsonMap
A JSON-compatible object/map with string keys and dynamically-typed values.
JsonValue
A JSON-compatible dynamically-typed value.
ScalarError
A custom scalar conversion failure.
ScalarLiteralMap
GraphQL literal arguments retained for generated custom scalar conversion.