
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
graphql-filter-object
Advanced tools
graphql-filter-object is a library that can be used to filter objects and arrays according to a query, subscription or mutation specified via a gql object.
import buildGraphqlFilter from 'graphql-filter-object'
const objectFilter = buildGraphqlFilter(gql`
query GetCat($catName: String!) {
getCat(cats: $catName) {
name
qualities {
qualityName
loveliness
}
}
}
`)
const filtered = objectFilter.filter({
getCat: {
name: 'Mr Onions',
breed: 'Major Springer',
qualities: [
{
qualityName: 'Cuddliness',
loveliness: 4_000,
usefulness: -10,
},
{
qualityName: 'Fighting',
loveliness: -10,
usefulness: 20,
},
],
},
})
After running this, filtered will equal:
const filtered = {
getCat: {
name: 'Mr Onions',
qualities: [
{
qualityName: 'Cuddliness',
loveliness: 4_000,
},
{
qualityName: 'Fighting',
loveliness: -10,
},
],
},
}
Also supports fragments:
import buildGraphqlFilter from 'graphql-filter-object'
const objectFilter = buildGraphqlFilter(
gql`
fragment QualitiesFragment on CatQualities {
qualityName
loveliness
}
fragment BigCatQualitiesFragment on BigCatQualities {
qualityName
fierceness
}
query GetCat($catName: String!) {
getCat(cats: $catName) {
name
qualities {
...QualitiesFragment
...BigCatQualitiesFragment
}
}
}
`,
)
const filtered = filter.filter({
getCat: [
{
name: 'Turback',
weight: 9_000,
qualities: [
{
__typename: 'BigCatQualities',
qualityName: 'furry',
loveliness: 60,
fierceness: 100,
annoying: 10,
},
{
__typename: 'BigCatQualities',
qualityName: 'cuddly',
loveliness: 100,
fierceness: 19,
annoying: 0,
},
],
},
{
name: 'Fluff-hunter',
weight: 0.1,
qualities: [
{
__typename: 'CatQualities',
qualityName: 'furry',
loveliness: 60,
fierceness: 27,
annoying: 10,
},
],
},
],
})
After running this, filtered will equal:
const filtered = {
getCat: [
{
name: 'Turback',
qualities: [
{
qualityName: 'furry',
fierceness: 100,
},
{
qualityName: 'cuddly',
fierceness: 19,
},
],
},
{
name: 'Fluff-hunter',
qualities: [
{
qualityName: 'furry',
loveliness: 60,
},
],
},
],
}
FAQs
filter objects and arrays according to a graphql-tag
We found that graphql-filter-object demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.