Skip to content

Tamp GraphQLCodegen

Scott Singleton edited this page May 15, 2026 · 2 revisions

Tamp.GraphQLCodegen

Wrapper for graphql-code-generator 5 — generates typed clients from a GraphQL schema. Small CLI surface; the plugin ecosystem shifts independently.

using Tamp.GraphQLCodegen.V5;

Full reference: https://github.com/tamp-build/tamp-graphql-codegen.

Verbs

GraphQLCodegen.Generate(tool, s =>)   // the default invocation (no subverb token)
GraphQLCodegen.Init(tool, s =>)       // interactive scaffold
GraphQLCodegen.Raw(tool,)             // escape hatch

Common flags (all verbs): --silent, --verbose, --debug, --errors-only, --profile, --require <module> (repeatable, order-preserving).

Generate-specific: --config, --overwrite, --watch [pattern], --project.

Plugin resolution gotcha

The plugins (@graphql-codegen/typescript, @graphql-codegen/typescript-operations, …) are not bundled with @graphql-codegen/cli. They have to be installed separately and resolvable from the project's CWD. In CI we install them globally and let Node's NODE_PATH fallback find them; in production builds they're in devDependencies so CWD resolution Just Works.

If you ever see this error chain from codegen:

[FAILED] - codegen-typescript
[FAILED] - codegen-typescript-template
[FAILED] - typescript

…it means the plugin packages aren't reachable from the working directory. Add them to package.json or set NODE_PATH to point at the global node_modules.

Quick example

[NuGetPackage("graphql-codegen", UseSystemPath = true)]
readonly Tool Codegen = null!;

Target Codegen => _ => _.Executes(() =>
    GraphQLCodegen.Generate(Codegen, s => s
        .SetConfig("codegen.ts")
        .SetOverwrite()
        .SetWorkingDirectory(RootDirectory / "frontend")));

See also

Settings authoring style

The example(s) above use the fluent Set*-chain shape. Every wrapper verb on this page also accepts a new XxxSettings { ... } object-init form. Both produce identical CommandPlans; the fluent shape stays canonical in docs and the tamp init template. See Build Script Authoring → Two authoring styles for the side-by-side comparison.

Clone this wiki locally