Registry / testing / typescript-graphql-typed-files-modules

typescript-graphql-typed-files-modules

JSON →
library0.2.1jsnpmunverified

A graphql-codegen plugin that generates TypeScript type definitions for .gql files using TypedDocumentNode, providing type-safe GraphQL documents. Current version 0.2.1, updated frequently. The plugin extends the standard typescript-graphql-files-modules by leveraging @graphql-typed-document-node/core to infer variables and data types for hooks like useQuery/useMutation, enhancing IDE support in VSCode. It requires graphql >=14.6.0 and @graphql-typed-document-node/core.

npm install typescript-graphql-typed-files-modules
INSTALL
IMPORT
SIG · TYPESCRIPT-GRAPHQL
T
typescript-graphql-typed-files-modules
testingjavascriptv0.2.1
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.

TypedDocumentNode
import { TypedDocumentNode } from '@graphql-typed-document-node/core'
import TypedDocumentNode from '@graphql-typed-document-node/core'
Named export, not default. This is a core type utilized by generated files.
generated query/mutation document (e.g., authors)
import authors from './authors.gql';
import { authors } from './authors.gql';
Generated .gql.d.ts files export a named const for the document AND a default export of the same value. Use default import for cleaner code.
preset 'near-operation-file'
preset: 'near-operation-file'
preset: 'near-operation'
The preset name is 'near-operation-file' (with hyphens). Incorrect preset name will cause codegen to fail without clear error.

Shows minimal codegen configuration using the plugin with near-operation-file preset for type-safe .gql imports.

// codegen.yml schema: schema.gql documents: src/**/*.gql generates: src/graphql/types.ts: plugins: - typescript config: enumsAsTypes: true skipTypename: true onlyOperationTypes: true src: preset: near-operation-file presetConfig: extension: .gql.d.ts baseTypesPath: graphql/types.ts plugins: - add: content: "/* Generated File. Do not modify directly. */" - typescript-operations - typescript-graphql-typed-files-modules config: skipTypename: true
Debug
Known issues
gotchaGenerated .gql.d.ts files must be included in tsconfig.json for TypeScript to find them
fix
Add '*.gql.d.ts' to include or use include pattern that picks up .d.ts files.
affects: >=0.0
breakingPlugin requires @graphql-typed-document-node/core v3, older v2 types are incompatible
fix
Install @graphql-typed-document-node/core@^3
affects: >=0.2.0
gotchaThe 'add' plugin must be listed before 'typescript-graphql-typed-files-modules' to prepend header
fix
Reorder plugins in codegen.yml: - add - typescript-operations - typescript-graphql-typed-files-modules
affects: >=0.0
deprecatedThis plugin is a fork of apollo-typed-documents. Do not confuse with original; usage patterns differ.
fix
Use this plugin instead of apollo-typed-documents for latest features.
affects: >=0.0
Errors
Common errors & fixes
Cannot find module './authors.gql' or its corresponding type declarations.
tsconfig.json is not including generated .gql.d.ts files, or generated files don't exist yet.
fix
Run graphql-codegen first. Ensure tsconfig includes 'src/**/*.gql.d.ts' or uses allowArbitraryExtensions.
Type error: Property 'authors' does not exist on type 'typeof import("./authors")'.
Incorrect import style: using named import instead of default import.
fix
Use 'import authors from "./authors.gql"' (default import).
Unknown preset "near-operation"
Typo in preset name 'near-operation-file'
fix
Use preset: 'near-operation-file'
Plugin typescript-graphql-typed-files-modules requires @graphql-typed-document-node/core to be installed.
Missing peer dependency
fix
Install both graphql and @graphql-typed-document-node/core
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
graphqlrequiredRequired peer dependency for graphql-codegen and DocumentNode usage
@graphql-typed-document-node/corerequiredCore dependency for TypedDocumentNode type
Agent activity
6 hits · last 30 days
node
6
Resources
typescript-graphql-typed-files-modules — npm install typescript-graphql-typed-files-modules · libregistry