Registry / api-client / gqty
library3.6.0jsnpmunverified

GQty is a No-GraphQL client for TypeScript that auto-generates a fully typed client from your GraphQL schema, eliminating manual query writing. Current stable version is 3.6.0. It uses a proxy-based approach to automatically track data requirements and generate optimal queries. Compared to other clients like Apollo or Urql, GQty removes boilerplate and provides real-time type safety, making it ideal for TypeScript-heavy projects. It ships TypeScript types, supports subscriptions via graphql-ws and SSE via graphql-sse, and has a growing community on Discord.

npm install gqty
INSTALL
IMPORT
SIG · GQTY
G
gqty
api-clientjavascriptv3.6.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.

createClient
import { createClient } from 'gqty'
const { createClient } = require('gqty')
Package is ESM-only; use import syntax.
useQuery
import { useQuery } from '@gqty/react'
import { useQuery } from 'gqty'
Hooks are provided by the separate @gqty/react package.
subscribe
import { subscribe } from '@gqty/subscriptions'
import { subscribe } from 'gqty'
Subscription functionality is in @gqty/subscriptions package.
type from generated schema
import { Query } from './gqty'
import { Query } from 'gqty'
Generated types are local to your project, typically in a './gqty' file.

Shows how to create a GQty client and execute a simple query to fetch a field named 'hello'.

import { createClient } from 'gqty'; const client = createClient({ url: process.env.GRAPHQL_URL ?? 'http://localhost:4000/graphql', // optional: headers, fetch options, etc. }); // Example: fetch a query const query = client.query({ hello: true }); const data = await query; console.log(data); // { hello: '...' }
Debug
Known issues
gotchaGQty uses a proxy that tracks property access; lazy evaluation may cause unexpected network requests if you access fields outside of rendering or without caching context.
fix
Ensure data access happens within React components or with explicit await on queries.
affects: >=3.0.0
breakingVersion 3.0 introduced a new API with createClient and removed the old createReactClient. Existing code using v2.x must be rewritten.
fix
Use createClient from 'gqty' and @gqty/react for hooks instead of previous monolithic imports.
affects: >=3.0.0
deprecatedThe 'useMutation' hook was removed; mutations are now performed via client.mutation() or the 'useTransaction' hook.
fix
Replace useMutation with client.mutation() in event handlers or use useTransaction from @gqty/react.
affects: >=3.0.0
gotchaGQty requires a running GraphQL server; it does not work with static schema files only unless you use a codegen step.
fix
Ensure your GraphQL endpoint is accessible during development and runtime.
affects: >=1.0.0
breakingPeer dependencies graphql-ws and graphql-sse must be installed manually. Missing them causes runtime errors when using subscriptions.
fix
Install: npm install graphql-ws graphql-sse
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module 'gqty' or its corresponding type declarations.
Missing npm install or incorrect import path.
fix
Run: npm install gqty
TypeError: client.query is not a function
Using an older version of GQty without the createClient API.
fix
Upgrade to GQty v3 and use createClient correctly: import { createClient } from 'gqty'
Missing field 'any' on type 'Query' in generated gqty file
The GraphQL schema does not contain that field, or the schema has changed and generated code is stale.
fix
Regenerate the client: npx gqty generate
Uncaught (in promise) Error: Network error: Response not successful - Received status code 400
The GraphQL server returned an error, possibly due to invalid query.
fix
Check server logs and ensure your query matches the schema. Use client.$query to inspect the generated query.
Upgrade
Version history
3.6.0latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency for GraphQL schema and execution utilities.
graphql-wsrequiredPeer dependency for WebSocket-based subscriptions.
graphql-sserequiredPeer dependency for Server-Sent Events-based subscriptions.
Agent activity
35 hits · last 30 days
node
32
Resources
packagegqty
gqty — npm install gqty · libregistry