Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@graphql-codegen/typed-document-node
Advanced tools
GraphQL Code Generator plugin for generating ready-to-use TypedDocumentNode based on GraphQL operations
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.
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' };
This package is part of the same GraphQL Code Generator ecosystem. It focuses on generating TypeScript types for GraphQL schema. Compared to @graphql-codegen/typed-document-node, it does not directly generate typed document nodes but rather the types that can be used to manually create typed documents.
While primarily a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL, Apollo Client can be configured to use TypeScript for type safety. It differs from @graphql-codegen/typed-document-node in that it's an all-in-one solution that includes client-side data fetching and caching, rather than just a code generation tool.
FAQs
GraphQL Code Generator plugin for generating ready-to-use TypedDocumentNode based on GraphQL operations
The npm package @graphql-codegen/typed-document-node receives a total of 1,916,581 weekly downloads. As such, @graphql-codegen/typed-document-node popularity was classified as popular.
We found that @graphql-codegen/typed-document-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.