Registry / devops / graphql-zeus

graphql-zeus

JSON →
library7.2.1jsnpmunverified

A strongly-typed GraphQL client generator that produces TypeScript types and helper functions from your GraphQL schema. Current stable version 7.2.1 (2024) releases frequently. Key differentiators: generates a complete client library (not just types), supports aliases, union/interface resolution, typedDocumentNode for Apollo/urql, custom scalars, and Thunder helper for custom fetch. Unlike graphql-codegen, Zeus provides a builder-pattern client that enforces typed selections without code generation on queries. Works in Node, browser, React Native.

npm install graphql-zeus
INSTALL
IMPORT
SIG · GRAPHQL-ZEUS
G
graphql-zeus
devopsjavascriptv7.2.1
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.

Gql
import { Gql } from './zeus'
import Gql from './zeus'
Named export from generated client folder, not default
Zeus
import { Zeus } from './zeus'
const { Zeus } = require('./zeus')
ESM modules require import syntax; CommonJS require works but is not recommended
$
import { $ } from './zeus'
import $ from './zeus'
The $ helper is a named export for creating variables
Selector
import { Selector } from './zeus'
Use for building reusable query selections
Thunder
import { Thunder } from './zeus'
import { Thunder } from 'graphql-zeus'
Thunder is exported from the generated file, not the npm package
typedGql
import { typedGql } from './zeus/typedDocumentNode'
import { typedGql } from './zeus'
typedGql is in a separate generated file for TypedDocumentNode support

Generates a client from a GraphQL endpoint, then executes a typed query with variables.

// 1. Generate client (run once) // npx graphql-zeus https://your.graphql/endpoint ./zeus --typescript // 2. Use generated client import { Gql, $ } from './zeus'; const getCards = async () => { const card = await Gql('query')({ drawCard: [ { cardId: $('id', 'String!') }, { id: true, name: true, Attack: true } ] }, { variables: { id: 'abc' } }); console.log(card.drawCard); };
Debug
Known issues
breakingVersion 6.x changed the output structure; generated files now put typedDocumentNode in a separate file.
fix
Regenerate client with v7 CLI. Import typedGql from './zeus/typedDocumentNode' instead of './zeus'.
affects: <7.0
breakingIn v5, Gql('mutation') required different syntax; v6+ unified query/mutation.
fix
Use the same syntax for both queries and mutations; pass operation type as first argument.
affects: >=6.0
deprecatedThe 'Chain' export from older versions (v4 and below) is deprecated and removed in v6.
fix
Replace Chain usage with Gql or Thunder.
affects: >=6.0
gotchaVariable definitions use $('name', 'GraphQLType') and must match the schema exactly (including '!' for non-null).
fix
Ensure type strings match schema; e.g., $('id', 'String!') not $('id', 'string')
affects: *
gotchaThe generated client respects custom scalar encode/decode provided via ZeusScalars, but defaults to identity.
fix
If scalars are missing, define them with ZeusScalars to avoid runtime errors.
affects: *
Errors
Common errors & fixes
Cannot find module './zeus' or its corresponding type declarations
Generated client folder not found or not imported correctly
fix
Run npx graphql-zeus <endpoint> ./zeus --typescript and ensure import path matches the folder name.
Type 'undefined' is not assignable to type '...'
Variable type mismatch or missing variable definition
fix
Check that variables defined with $() match the schema type exactly, including required (!) and that variables object keys match.
Property 'drawCard' does not exist on type '...'
The query field name in the response object might be aliased or the query object structure is wrong
fix
Use __alias in the query object to match expected response shape: { __alias: { myCards: { drawCard: { ... } } } }
Upgrade
Version history
7.2.1latest on npm
Audit
Dependencies
graphqlrequiredRequired for type generation and schema introspection
Agent activity
9 hits · last 30 days
node
8
Resources
graphql-zeus — npm install graphql-zeus · libregistry