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 } });
Errors
Common errors & fixes
Cannot find module './zeus' or its corresponding type declarations.
Generated client not created or import path incorrect.
fixRun 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.
fixCheck 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.
fixAdd 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.
fixEnsure 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.
fixUse the exact response shape as returned; avoid destructuring aliased fields without the alias name.
Audit
Dependencies
graphql-wsoptionalRequired for WebSocket subscriptions; must be installed separately (peer dependency).