
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
graphql-codegen-typescript-typedefs
Advanced tools
Adds the combined graphql schema (string) and type definitions (DocumentNode) to the generated typescript file.
Adds the combined graphql schema (string) and type definitions (DocumentNode) to the generated typescript file.
Useful whenever you need the type definitions as a DocumentNode.
Warning:
The generated values are not just types, but actual values and may contribute to your bundle size.
yarn add --dev graphql-codegen-typescript-typedefs
npm install --save-dev graphql-codegen-typescript-typedefs
Add the typescript-typedefs plugin to your codegen config.
Ex.
# codegen.yaml
generates:
generated-types.ts:
schema: "**/*.graphqls"
plugins:
- typescript
- typescript-typedefs
The following variables will be exported by the generated file:
| Variable Name | Type | Content |
|---|---|---|
| Schema | string | The combined GraphQL schema in a compact string |
| TypeDefs | DocumentNode | The type definitions of the combined schema |
Prefix the variables with this string.
Parse the schema string directly in the generated code by using gql from graphql-tag.
This is useful if you want to keep the generated code as small as possible.
This option can be used together with parseSchema.
Generate import { gql } from "graphql-tag" instead of import gql from "graphql-tag"
import { TypeDefs } from "generated-types";
// ...
const server = new ApolloServer({ typeDefs: TypeDefs, resolvers });
FAQs
Adds the combined graphql schema (string) and type definitions (DocumentNode) to the generated typescript file.
We found that graphql-codegen-typescript-typedefs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.