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.
graphql-add-remove-fields
Advanced tools
Add or remove fields in graphql queries
This package will recursively add or remove a specific field name in all selection sets within the query.
One example usage is adding the __typename
field to all selection sets in all outgoing queries and using this together with a normalized cahcing strategy such as graphql-norm to generate a unique ID for each normalized object.
npm install graphql-add-remove-fields --save
The package exports two functions, addFields
and removeFields
. They accept a GraphQL AST and an array of field names to add/remove and returns a new GraphQL AST. The original AST used as input is not modified. Adding fields that already exists will be silently ignored. Removing fields that does not exist will be silently ignored.
Here is a small example:
import gql from "graphql-tag";
import { addFields, removeFields } from "graphql-add-remove-fields";
const query = gql`
query MyQuery {
user(id: 10) {
firstName
lastName
}
}
`;
// This will add the __typename field to all selection sets in the query
const queryAdded = addFields(query, ["__typename"]);
/*
The query is now:
query MyQuery {
user(id: 10) {
firstName
lastName
__typename
}
__typename
}
*/
// This will remove the added fields so we will get back the original query
const queryRemoved = removeFields(queryAdded, ["__typename"]);
yarn version --patch
yarn version --minor
yarn version --major
FAQs
Add or remove fields in graphql queries
We found that graphql-add-remove-fields demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 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’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.