Skip to content

Latest commit

 

History

History

wesley-emit-typescript

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

wesley-emit-typescript

Part of Wesley. Emits TypeScript declarations from Wesley's L1 IR.

let ir = wesley_core::lower_schema_sdl(sdl)?;
let operations = wesley_core::list_schema_operations_sdl(sdl)?;

let declarations = wesley_emit_typescript::emit_typescript(&ir);
let with_bindings = wesley_emit_typescript::emit_typescript_with_operations(&ir, &operations);

emit_typescript gives one declaration for each type in the IR:

GraphQL TypeScript
object or input type export interface, extending what it implements
interface export interface
enum a union of string literals: "RED" | "GREEN"
union a union of the member types: Cat | Dog
custom scalar export type Name = unknown;
built-in scalar nothing; fields use number, string, boolean

The _with_operations form adds, for each root operation, a request interface, a response type, and a typed operation descriptor, and in their place it leaves out the Query, Mutation, and Subscription types themselves. The crate also emits little-endian binary codecs from the plan in wesley-emit-codec. The wesley emit typescript and wesley emit le-binary-typescript commands are this crate behind a command line.

The output begins with /* @generated by Wesley. Do not edit. */ and is deterministic: the same IR and operation list give the same bytes. Output that includes operation bindings depends on both, so do not cache it by the IR hash alone.

Wesley is pre-1.0. Emitted code may change between releases. Apache-2.0.