$ show remorses/genql
Genql is a type-safe GraphQL query builder that generates TypeScript clients from GraphQL schemas. The core functionality resides in the CLI (@genql/cli) which introspects a GraphQL schema and emits a client enabling compile-time query validation and autocompletion. The repository also includes a Next.js website for documentation and a converter tool, plus a scraper subsystem that automatically discovers public GraphQL APIs via Sourcegraph, generates clients, and publishes them to npm. The architecture is a monorepo managed by pnpm with three main components: cli (code generation and runtime), website (documentation and converter), and scraper (automated discovery and publishing). Key features include batching queries, subscriptions, framework-agnostic design, and support for Node.js, browser, Deno, and Cloudflare environments.
The LLM identified 4 files worth highlighting for reuse:
Implements a reusable QueryBatcher class that combines multiple GraphQL requests based on configurable time intervals or batch sizes. Framework-agnostic design depends only on a fetch function, making it extractable for any HTTP batching scenario. Demonstrates advanced request coalescing with proper error handling and lifecycle management.
Core type system enforcing valid GraphQL field selection at compile time through sophisticated TypeScript mapped and conditional types. Enables autocompletion and prevents invalid queries without runtime checks. Highly reusable pattern applicable to any schema-driven API client generation where compile-time validation is desired.
Manages code generation state by accumulating imports and code blocks during AST traversal. Allows modular contribution to output without tight coupling between generator components. Implements a writer monad pattern that is easily adaptable to other code generation tasks beyond GraphQL.
Provides reusable utilities for CSV handling (reading/writing) and fetching metadata (title, description, favicon) from web pages with robust error handling, timeouts, and Open Graph tag parsing. Demonstrates production-grade web scraping patterns applicable to any data enrichment or discovery pipeline.