Registry / testing / graphql-zeus-core

graphql-zeus-core

JSON →
library7.2.1jsnpmunverified

Strongly Typed GraphQL client library generated by Zeus CLI (v7.2.1). Provides type-safe GraphQL queries, mutations, and subscriptions with full TypeScript support. Key differentiators: uses schema to generate typed clients, supports variables via $ helper, reusable Selectors, custom fetch via Thunder, and TypedDocumentNode for Apollo/urql. Ships ESM and CommonJS, requires graphql-ws >=5 for subscriptions. Active development with monthly releases.

npm install graphql-zeus-core
INSTALL
IMPORT
SIG · GRAPHQL-ZEUS-CORE
G
graphql-zeus-core
testingjavascriptv7.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 'graphql-zeus-core'
The generated client lives in a local path (default './zeus'), not the npm package. The package provides the generator CLI.
Thunder
import { Thunder } from './zeus'
import Thunder from 'graphql-zeus-core'
Thunder is a factory for custom fetch chains; it's exported from the generated './zeus' module.
Selector
import { Selector } from './zeus'
Used to create reusable selection sets. Only named export, no default export.
$
import { $ } from './zeus'
import { $ } from 'graphql-zeus-core'
The $ helper is for declaring variables with types; it's part of the generated client.
typedGql
import { typedGql } from './zeus/typedDocumentNode'
import { typedGql } from './zeus'
typedDocumentNode for Apollo/urql is in a separate generated file.

Shows four ways to query GraphQL with Zeus: built-in Gql, custom Thunder, variables via $, reusable Selectors, and typedDocumentNode for Apollo clients.

import { Gql, Thunder, Selector, $ } from './zezerus'; import { typedGql } from './zezerus/typedDocumentNode'; const endpoint = process.env.GRAPHQL_ENDPOINT ?? 'http://localhost:4000/graphql'; // Using Gql (built-in Chain with fetch) const gql = Gql('http://localhost:4000/graphql'); const rocket = await gql('query')({ rocket: [{ id: 1 }, { name: true, type: true }] }); console.log('Rocket:', rocket); // Using Thunder for custom fetch const thunder = Thunder(async (query) => { const res = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query }) }); const json = await res.json(); return json.data; }); const data = await thunder('query')({ rockets: { name: true } }); console.log('Rockets:', data.rockets); // With variables const rocketById = await gql('query')({ rocket: [{ id: $('id', 'Int!') }, { name: true }] }, { variables: { id: 1 } }); // Reusable selector const rocketSelector = Selector('Query')({ rocket: [{ id: $('id', 'Int!') }, { name: true, type: true }] }); type RocketQuery = InputType<GraphQLTypes['Query'], typeof rocketSelector>; const result = await gql('query')(rocketSelector, { variables: { id: 2 } }); // typedGql for Apollo const doc = typedGql('query')({ rockets: { name: true } });
Debug
Known issues
gotchaImports must come from the generated './zeus' directory, not from the 'graphql-zeus-core' npm package.
fix
Use import { Gql } from './zeus' (adjust path as generated).
affects: >=1.0.0
gotchaVariables declared with $ must also be passed in the variables option object; missing variables cause runtime GraphQL errors.
fix
Always provide { variables: { varName: value } } as second argument to the query.
affects: >=1.0.0
breakingVersion 7 changed the exported names from 'Api' to 'Gql', 'ZeusSelect' to 'Selector', 'Thunder' remains same.
fix
Update imports: import { Gql, Selector } from './zeus'.
affects: >=7.0.0 <7.0.0
deprecatedUse of raw 'Zeus' function to generate GQL strings is still supported but not recommended; prefer 'Gql' or 'Thunder' for full type-safety.
fix
Use Gql Chain or Thunder for automatic execution.
affects: >=7.0.0
gotchaSubscriptions require graphql-ws peer dependency; not installing it leads to runtime errors when using subscriptions.
fix
npm install graphql-ws.
affects: >=1.0.0
gotchaInterface/union selections must use inline fragment syntax with string keys like '...on Type', not the spread operator.
fix
Use { __typename: true, '...on MyType': { field: true } }.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module './zeus' or its corresponding type declarations.
Generated client not created or import path incorrect.
fix
Run the Zeus CLI to generate the client: npx zeus https://your-schema-url ./zeus --typescript. Then import from that path.
Property 'Gql' does not exist on type 'typeof import("./zeus")'.
Using older syntax (Gql renamed in v7) or import path points to wrong file.
fix
Check generated exports; use import { Gql } from './zeus' and ensure CLI version >=7.
Expected 2 arguments, but got 1.
When using variables you omitted the variables option object.
fix
Add second argument: Gql('query')(queryObject, { variables: { key: value } }).
Variable "$id" got invalid value null.
Passed null to a non-null variable (declared with !) or omitted variable entirely.
fix
Ensure all declared non-null variables are provided with a valid value.
Cannot read properties of undefined (reading 'rocket')
Response data structure may be nested; accessing a field that wasn't requested or is aliased.
fix
Use the exact response shape as returned; avoid destructuring aliased fields without the alias name.
Upgrade
Version history
7.2.1latest on npm
Audit
Dependencies
graphql-wsoptionalRequired for WebSocket subscriptions; must be installed separately (peer dependency).
Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources