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

@graphql-codegen/typescript

Package Overview
Dependencies
Maintainers
5
Versions
5946
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

  • 1.0.4-alpha-c6523e75.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
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 24 Mar 2019

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