Socket
Socket
Sign inDemoInstall

@graphql-codegen/typescript

Package Overview
Dependencies
197
Maintainers
4
Versions
5656
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-codegen/typescript

GraphQL Code Generator plugin for generating TypeScript types


Version published
Maintainers
4
Weekly downloads
3,222,441
increased by1.56%
Install size
21.3 MB

Weekly downloads

Package description

What is @graphql-codegen/typescript?

The @graphql-codegen/typescript package is a powerful tool designed for generating TypeScript typings directly from GraphQL schemas and operations. It automates the process of creating type definitions, making it easier to work with GraphQL in TypeScript projects by ensuring type safety and reducing the manual effort required to keep types in sync with the GraphQL schema.

What are @graphql-codegen/typescript's main functionalities?

Generating TypeScript Types from a GraphQL Schema

This feature allows you to generate TypeScript interfaces and types from a GraphQL schema. The code sample demonstrates how to programmatically generate TypeScript types using the GraphQL Code Generator CLI.

const { generate } = require('@graphql-codegen/cli');

async function generateTypes() {
  const output = await generate(
    {
      schema: './schema.graphql',
      generates: {
        './types.ts': {
          plugins: ['typescript']
        }
      }
    },
    true
  );
}
generateTypes();

Generating TypeScript Operations (Queries, Mutations, Subscriptions)

This feature generates TypeScript types for GraphQL operations, such as queries, mutations, and subscriptions. The code sample shows how to generate types for operations, enhancing type safety and development experience in TypeScript projects.

const { generate } = require('@graphql-codegen/cli');

async function generateOperations() {
  const output = await generate(
    {
      schema: './schema.graphql',
      documents: './src/**/*.graphql',
      generates: {
        './graphql.ts': {
          plugins: ['typescript', 'typescript-operations']
        }
      }
    },
    true
  );
}
generateOperations();

Other packages similar to @graphql-codegen/typescript

FAQs

Last updated on 22 Feb 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc