Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
gql-ts-builder
Advanced tools
The main goal of this package is simplify creation of graphql queries
This npm package aims to simplify the process of creating GraphQL queries by providing a type-first approach. It addresses common issues such as mistyped field names and inconsistencies between query fields and types.
With this package, you can:
npm install gql-ts-builder
import { useQuery, gql, DocumentNode } from "@apollo/client";
import { createQueryBuilder, InferSelection } from "gql-ts-builder";
// Define types
type User = {
id: string;
name?: string;
email: string;
};
// Set up query builder
const buildUserQuery = createQueryBuilder<User, DocumentNode>(
(selection) => gql`
query User {
user {
${selection}
}
}
`
);
// Construct a query
const query = buildUserQuery({
id: true,
name: true,
});
// Infer result types
// Payload type will be { id: string; name?: string; }
type Payload = InferSelection<typeof query>;
type Data = {
user: Payload;
};
// Create custom hook
export const useUser = () => {
const { data, loading, error } = useQuery<Data>(query);
return {
userData: data?.user,
userLoading: loading,
userError: error,
};
};
This package aims to enhance the developer experience when working with GraphQL, reducing errors and improving productivity.
FAQs
The main goal of this package is simplify creation of graphql queries
We found that gql-ts-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.