Registry / ai-ml / graphql-ts-client

graphql-ts-client

JSON →
library10.4.0jsnpmunverified

Generate fully typed TypeScript clients for any GraphQL API. Version 10.4.0 targets Node >=12, ships TypeScript types, and is actively maintained. Key differentiators: client generation with runtime URL/header/retry configuration, response listeners, and alias support. Unlike alternatives like graphql-request or Apollo Client, it separates code generation from runtime usage, producing a standalone client file that can be imported without additional dependencies.

npm install graphql-ts-client
INSTALL
IMPORT
SIG · GRAPHQL-TS-CLIENT
G
graphql-ts-client
ai-mljavascriptv10.4.0
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.

generateTypescriptClient
import { generateTypescriptClient } from 'graphql-ts-client'
import generateTypescriptClient from 'graphql-ts-client'
Named export only. No default export.
myAwesomeApi
import { myAwesomeApi } from './myAwesomeApi'
The generated client file exports a default client instance by default (name based on output filename).

Generates a TypeScript client from a GraphQL endpoint and uses it to query users.

import { generateTypescriptClient } from 'graphql-ts-client' import * as fs from 'fs/promises' generateTypescriptClient({ output: './myApi.ts', endpoint: process.env.GRAPHQL_ENDPOINT ?? 'https://api.example.com/graphql', headers: { Authorization: `Bearer ${process.env.AUTH_TOKEN ?? ''}`, }, }) // Generated client usage: import { myApi } from './myApi' async function fetchData() { const response = await myApi.queries.users({ __args: { limit: 10 }, id: true, name: true, email: true, }) console.log(response.users) }
Debug
Known issues
breakinggenerateTypescriptClient now requires the 'endpoint' option to be a non-empty string.
fix
Ensure endpoint is provided and valid.
affects: >=10.0.0
deprecatedThe 'verbose' option is deprecated. Use a custom before hook or logger instead.
fix
Remove verbose option and implement custom logging if needed.
affects: >=9.0.0
gotchaGenerated client method names are derived from the GraphQL query/mutation names. Ensure your schema conforms to GraphQL naming conventions or expect snake_case to be converted to camelCase.
fix
Use __alias to override the method name if needed.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: generateTypescriptClient is not a function
Using default import instead of named import.
fix
Use import { generateTypescriptClient } from 'graphql-ts-client'
Error: Invalid endpoint provided
Missing or empty endpoint option.
fix
Provide a valid GraphQL endpoint URL in the generateTypescriptClient call.
Upgrade
Version history
10.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
graphql-ts-client — npm install graphql-ts-client · libregistry