gazania
v0.15.0
Published
Gazania lets you write GraphQL operations as TypeScript code with full type inference, autocompletion, and compile-time error checking.
Readme
Gazania
Gazania lets you write GraphQL operations as TypeScript code with full type inference, autocompletion, and compile-time error checking.
Quick Start
Install:
pnpm add gazaniaGenerate types from your schema:
npx gazania generate --schema https://api.example.com/graphql --output src/schema.tsBuild 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.
