gql.tada is a powerful and spec-compliant GraphQL document authoring library designed for TypeScript environments. Its primary function is to infer the result and variables types of GraphQL queries, mutations, and fragments directly within the TypeScript type system, eliminating the need for separate code generation steps. Currently at version 1.9.2, the library maintains an active development pace with frequent patch and minor releases, as evidenced by recent changelogs. A key differentiator is its deep integration with TypeScript, providing on-the-fly type safety, editor feedback, and auto-completion without external build steps, especially when paired with a language server like GraphQLSP. It achieves this by parsing GraphQL documents directly in TypeScript, deriving a schema from introspection and scalar configuration, and then mapping these definitions to robust result and variables types, including advanced features like fragment masks and gradual fragment unwrapping.
npm install gql.tadaVerified import paths — ran on the pinned version, not inferred.
Demonstrates defining GraphQL fragments and queries using the `graphql` tagged template literal, inferring result and fragment types with `typeof` and `FragmentOf`, and safely accessing data.
Upgrade your project's TypeScript version to 5.0.0 or higher. Ensure your `tsconfig.json` is correctly configured for your TypeScript version.
Install `@gql.tada/cli` and run `npx gql-tada init` followed by `npx gql-tada generate` to set up and update your schema definition file. Ensure your `tsconfig.json` includes the generated `.d.ts` files.
Upgrade `gql.tada` to version `1.8.13` or higher to ensure you have the fixes for external scalar handling. If using `@gql.tada/cli-utils` directly, upgrade it to `1.7.1` or higher.
Ensure you are using the latest stable TypeScript version (currently v5.x or v6.x). Consider optimizing your `tsconfig.json` settings, using a modern module resolution strategy like `NodeNext` or `Bundler`, and leveraging incremental builds or build caches if available in your project setup.
Ensure `@gql.tada/cli` is installed and run `npx gql-tada init` followed by `npx gql-tada generate`. Verify your `tsconfig.json` includes the generated `graphql-env.d.ts` file.
Check your `tsconfig.json` to ensure `graphql-env.d.ts` is included and that `moduleResolution` and `module` settings are compatible (e.g., `NodeNext` or `Bundler`). Restart your TypeScript language server or IDE to refresh type definitions.
Review the GraphQL query for typos or mismatches against your schema. If your schema has changed, run `npx gql-tada generate` to update your local schema definition file and then restart your TypeScript language server/IDE.