Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-codegen/typescript

Package Overview
Dependencies
Maintainers
4
Versions
5973
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-codegen/typescript

GraphQL Code Generator plugin for generating TypeScript types

  • 4.1.2-alpha-20241107081254-369607b2ee0b65f383cf7e5ad7487d214d9064ad
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

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

Package last updated on 07 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc