Skip to content

@gel/generate v0.7.0

Choose a tag to compare

@github-actions github-actions released this 23 Oct 19:03
· 2 commits to master since this release
e0ff26b

Selective Query Generation with Patterns

The queries generator now supports glob patterns as positional arguments, letting you selectively regenerate only the query files you need instead of processing your entire project. When working with large codebases, you can target specific directories or patterns like npx @edgedb/generate queries "src/user/**/*.edgeql" or process multiple locations at once with npx @gel/generate queries "critical/**.edgeql" "admin/*.edgeql". This is a boon when you might have multiple sub-folders that contain .edgeql files, or if the default file detection is picking up more files than you'd like.

# Only regenerate user-related queries
npx @gel/generate queries "**/*user*.edgeql"

# Regenerate queries from multiple specific directories  
npx @gel/generate queries "src/queries/" "admin/queries/"

Advanced TypeScript Types for Custom Scalars

The new --use-resolved-codec-type flag enables using advanced TypeScript type system features like branded types, template literal types, and union types for custom scalars. This is especially valuable when you have abstract scalars with regex constraints that map to template literal types (e.g., scalar type Email extending str { constraint regexp(...) }`${string}@${string}.${string}`), or when you want to use branded types for domain modeling (e.g., type UserId = string & { __brand: "UserId" }). While this doesn't change runtime decoding behavior, it provides stronger compile-time guarantees by letting you declare precise TypeScript types via module augmentation of the OverrideCodecType interface.

# Generate with customizable scalar types
npx @gel/generate queries --use-resolved-codec-type
// Then augment in your code for compile-time type safety:
declare module "gel" {
  interface OverrideCodecType {
    "default::Email": `${string}@${string}.${string}`; // Template literal type
    "default::UserId": string & { __brand: "UserId" }; // Branded type
  }
}

What's Changed

  • Add positional pattern support for gel generate queries by @nervetattoo in #1308
  • Make clear the implications of generated typescript queryfiles by @jackfischer in #1310
  • feat: allow users to customize the TypeScript type of a custom scalar by @freeatnet in #1313

New Contributors