Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@graphql-codegen/client-preset
Advanced tools
GraphQL Code Generator preset for client.
The @graphql-codegen/client-preset package is part of the GraphQL Code Generator ecosystem, designed to automatically generate ready-to-use, type-safe query and mutation hooks, as well as TypeScript types for your GraphQL operations. It streamlines the development process by generating code that integrates seamlessly with popular GraphQL client libraries, such as Apollo Client, URQL, and others. This preset is particularly useful for projects that use GraphQL for data fetching and manipulation, as it minimizes the need for manually writing boilerplate code and ensures type safety across your client-side data operations.
TypeScript Types Generation
Automatically generates TypeScript types for your GraphQL queries, mutations, and subscriptions based on your schema. This feature ensures type safety and autocompletion in your IDE, making it easier to work with GraphQL data in a TypeScript project. The code sample shows how to add a script to your package.json to run the code generation process.
"scripts": {
"generate": "graphql-codegen"
}
Hooks Generation for Apollo Client
Generates custom React hooks for your GraphQL operations when using Apollo Client. This allows you to easily execute queries and mutations with built-in loading, error, and data states. The code sample demonstrates how to import and use the generated hooks in a React component.
import { useMyQuery, useMyMutation } from './generated/graphql';
function MyComponent() {
const { data, loading, error } = useMyQuery();
const [mutate, { data: mutationData }] = useMyMutation();
// Use the hooks in your component
}
Document Nodes Generation
Generates GraphQL document nodes from your operations, which can be used with any GraphQL client library. This is useful for projects that might not use Apollo Client or URQL but still want to benefit from type-safe GraphQL operations. The code sample shows how to import and use the generated document nodes.
import { MY_QUERY_DOCUMENT, MY_MUTATION_DOCUMENT } from './generated/graphql';
// Use the document nodes with any GraphQL client
This is the core package of the GraphQL Code Generator ecosystem, of which @graphql-codegen/client-preset is a part. It provides the underlying functionality and plugin system for code generation but requires more configuration to achieve the same results as the client-preset.
Focuses on generating GraphQL schema and resolvers using TypeScript classes and decorators. While it serves a different part of the GraphQL ecosystem, focusing on server-side schema generation, it shares the goal of leveraging TypeScript for better development experience.
FAQs
GraphQL Code Generator preset for client.
The npm package @graphql-codegen/client-preset receives a total of 1,248,484 weekly downloads. As such, @graphql-codegen/client-preset popularity was classified as popular.
We found that @graphql-codegen/client-preset 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.