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

@graphql-codegen/typed-document-node

Package Overview
Dependencies
Maintainers
4
Versions
2141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-codegen/typed-document-node

GraphQL Code Generator plugin for generating ready-to-use TypedDocumentNode based on GraphQL operations

  • 5.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is @graphql-codegen/typed-document-node?

The @graphql-codegen/typed-document-node package is a plugin for the GraphQL Code Generator tool. It generates fully typed TypeScript documents from GraphQL operations and fragments. This enhances the development experience by providing type safety and autocompletion directly in the IDE, reducing the risk of runtime errors and improving code quality.

What are @graphql-codegen/typed-document-node's main functionalities?

Type-safe GraphQL operations

This feature allows developers to use GraphQL operations like queries, mutations, and subscriptions with complete type safety. The code sample demonstrates how to use a typed query with Apollo Client, ensuring that both the variables and the returned data conform to the expected types.

import { useQuery } from '@apollo/client';
import { MyQuery, MyQueryVariables } from './generated/graphql';

const { data, loading, error } = useQuery<MyQuery, MyQueryVariables>(MY_QUERY, { variables: { id: '1' } });

Integration with GraphQL fragments

This feature supports the use of GraphQL fragments, generating TypeScript types that can be extended or integrated into larger data structures. The code sample shows how to extend a generated fragment type with additional fields, leveraging TypeScript's type extension capabilities.

import { MyFragment } from './generated/graphql';

interface ExtendedType extends MyFragment {
  additionalField: string;
}

const extendedData: ExtendedType = { ...fragmentData, additionalField: 'extra' };

Other packages similar to @graphql-codegen/typed-document-node

FAQs

Package last updated on 22 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