npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@_zth/rescript-graphql-codegen

v0.1.0

Published

ReScript GraphQL operation code generation for rescript-embed-lang

Downloads

290

Readme

ReScript GraphQL Codegen

Typed ReScript GraphQL operation code generation with first-class support for rescript-embed-lang.

Install the published generator with:

yarn add --dev @_zth/rescript-graphql-codegen

Usage

Compiled operation artifacts

Set operationModule to a ReScript module whose make function accepts ~name, ~hash, and ~getDocument. Each generated operation then exposes an operation value typed as operationModule.t<variables, t>, plus the same value as default. Variables and results are trusted from the generated operation types; runtime validation is the responsibility of the configured client, not the generated descriptor.

With rescript-embed-lang 0.6.1 or newer, the embed CLI uses its first-class GraphqlDefinition strategy to derive a stable module name from the GraphQL operation name and emits one file per operation. A value embed therefore produces the typed operation directly:

let example = %generated.gqlExternalSchema(`
  query Example($id: ID!) {
    example(id: $id) {
      id
    }
  }
`)

await client->run(example, {id})

The generated module remains available as SourceFile__gqlExternalSchema__Example when callers need its variables, result t, schemas, or operation metadata. The embed CLI writes the rescript-embed-lang.json consumed by the PPX, keeping its extraction configuration identical to codegen.

Sury schemas can be generated independently from operation execution:

{
  operationModule: "GraphqlOperation",
  surySchemaGeneration: "fromDirective"
}

Opt an operation in with the codegen-only directive:

query Example($id: ID!) @gqlGenerator__generateSurySchema {
  example(id: $id) {
    id
  }
}

The directive emits the operation's variablesSchema and output schema artifacts. It is removed before the executable document and operation hash are generated. surySchemaGeneration also accepts "always" and "never". The older generateSurySchemas boolean remains supported when the new option is omitted.

Status

Mostly done

  • lib: contains
  • base-types: Baseline Rescript codegen plugin. Generates enum and input types.
  • operations: Baseline Rescript codegen plugin. Generates variable and output types.
  • test: Runs generated codegen plugins

TODO

  • near-re-operation-file: Planned output preset; the near-operation-file preset automatic generates Typescript imports, which need to be prevented with certain specific values in the presetConfig. Ideally, this would be a very similar equivalent that requires no special config.