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-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
The npm package graphql-add-remove-fields receives a total of 6 weekly downloads. As such, graphql-add-remove-fields popularity was classified as not popular.
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 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.