Registry / devops / megaera

megaera

JSON →
library1.0.2jsnpmunverified

GraphQL to TypeScript code generator that derives TypeScript types from GraphQL queries, fragments, and mutations. Version 1.0.2 is the latest stable release. It generates typed query function signatures (including variables and return types) directly from .graphql files, copying the query string into the output for easy reuse. Key differentiators: lightweight, no runtime dependency, supports Variables utility type, and outputs type-only imports. Unlike alternatives (GraphQL Code Generator, graphql-let), megaera focuses on simplicity and minimal configuration, with a single CLI command.

npm install megaera
INSTALL
IMPORT
SIG · MEGAERA
M
megaera
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Variables
import { Variables } from 'megaera'
import Variables from 'megaera'
Variables is a named export (utility type), not a default export.
IssuesQuery (generated type)
import type { IssuesQuery } from './query.graphql.ts'
import { IssuesQuery } from 'megaera'
Generated types are emitted alongside the query string in the output .graphql.ts file, not from the megaera package itself.
IssuesQuery (generated variable)
import { IssuesQuery } from './query.graphql.ts'
import { IssuesQuery } from 'megaera'
The query string variable is also exported from the generated .graphql.ts file.

Generates TypeScript types for all GraphQL queries, then imports and uses the generated query variable and its return type.

npx megaera --schema=schema.graphql ./src/**/*.graphql # Creates .graphql.ts files next to each .graphql file # Example usage in code: # import { IssuesQuery, type IssuesQuery as IssuesQueryType } from './query.graphql.ts' # type Result = ReturnType<IssuesQueryType>
Debug
Known issues
gotchaGenerated types are placed in .graphql.ts files alongside source .graphql files, not in a central directory.
fix
Ensure the glob pattern matches all .graphql files. Output location can be adjusted via --out-dir if needed.
affects: >=1.0
gotchaThe generated type for a query is a function type (e.g., type IssuesQuery = (vars: {...}) => {...}). Use ReturnType<IssuesQuery> to get the data shape, not directly.
fix
Use ReturnType<typeof importedVariable> or ReturnType<ImportedType> to extract the query result type.
affects: >=1.0
gotchaVariables type is extracted via Parameters<UserQuery>[0] or the Variables utility type from megaera. The Variables utility type is a named export.
fix
Use import { Variables } from 'megaera' then type Vars = Variables<UserQuery>.
affects: >=1.0
Errors
Common errors & fixes
Cannot find module 'megaera'
megaera is not installed or not in node_modules.
fix
Run 'npm install megaera' or 'yarn add megaera'.
Type 'IssuesQuery' is not generic
Trying to use generated type as a generic (e.g., IssuesQuery<SomeType>) but it's not generic; it's a function type.
fix
Use ReturnType<IssuesQuery> to get the result type.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
megaera — npm install megaera · libregistry