Graphql-ts-client-api (v3.1.17) provides a strongly typed, code-first approach for GraphQL clients in TypeScript/JavaScript. Automatically generates TypeScript types from GraphQL schema, enabling compile-time safety for queries, mutations, and subscriptions. Released regularly via npm, it supports both ESM and CJS, and integrates with popular HTTP clients like fetch and axios. Key differentiators: type-safe query building, zero runtime overhead, and seamless integration with graphql-ts-client-compiler for code generation.
npm install graphql-ts-client-apiNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating a fetcher with custom URL, auth headers, and executing a GraphQL query with variables.
Replace import client from 'graphql-ts-client-api' with import { createFetcher } from 'graphql-ts-client-api'.Replace createClient with createFetcher in your code.
Use `import type { RequestHeaders } from 'graphql-ts-client-api'` instead of value import.Install node-fetch or use global fetch in Node 18+, and pass it to createFetcher via the `fetch` option.
Always use static string literals for queries, or use a .graphql file loader.
Provide a fetch implementation explicitly when calling createFetcher.
Use named export: import { createFetcher } from 'graphql-ts-client-api'; then call createFetcher(...).Install node-fetch and pass it: createFetcher({ url: '...', fetch: require('node-fetch') })Ensure the object has a `query` string property: fetcher({ query: '...', variables: { ... } })Run `npm install graphql-ts-client-api` and use `const { createFetcher } = require('graphql-ts-client-api');`