Skip to content

Teages/gazania

Repository files navigation

Gazania

Gazania lets you write GraphQL operations as TypeScript code with full type inference, autocompletion, and compile-time error checking.

npm version npm downloads

Quick Start

Install:

pnpm add gazania

Generate types from your schema:

npx gazania generate --schema https://api.example.com/graphql --output src/schema.ts

Build typed queries:

import type { ResultOf } from 'gazania'
import { createGazania } from 'gazania'

const gazania = createGazania('https://api.example.com/graphql')

const userQuery = gazania.query('GetUser')
  .vars({ id: 'Int!' })
  .select(($, vars) => $.select([{
    user: $ => $.args({ id: vars.id }).select([
      'id',
      'name',
      'email',
    ]),
  }]))

type Result = ResultOf<typeof userQuery>
// { user: { id: number, name: string, email: string } }

📖 Full documentation: gazania.teages.dev

License

Published under MIT License.

About

Gazania lets you write GraphQL operations as TypeScript code with full type inference, autocompletion, and compile-time error checking.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages