
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.
Quering GraphQL service never been so simple.
NPM:
npm install --save graphoon
YARN:
yarn add graphoon
Simple query.
import { query, q } from "graphoon";
(async function() {
const id = 10;
const { user, roles } = await query`
user(id: ${id}) {
id
name
surname
role {
id
}
}
roles {
id
title
}
`;
// user variable can look like this:
// {
// id: 10,
// name: 'John',
// surname: 'White',
// role: {
// id: 1
// }
// }
// roles variable can look like this:
// [
// {id: 1, title: 'Admin'},
// {id: 2, title: 'Developer'},
// {id: 3, title: 'Reporter'}
// ]
const { profiles } = await q(`
profiles(userId: ${id}) {
id
type
active
}
`);
// profiles variable can look like this:
// [
// {id: 1, type: 'common', active: true},
// {id: 2, type: 'custom', active: false}
// ]
})();
Mutating data on server.
import { mutation, m } from "graphoon";
(async function() {
const id = 10;
const name = "Rose";
const surname = "Mary";
const { updateUser } = await mutation`
updateUser(id: ${id}, data: {
name: ${name},
surname: ${surname}
}) {
id
name
surname
role {
id
}
}
`;
// updateUser variable can look like this:
// {
// id: 10,
// name: 'Rose',
// surname: 'Mary',
// role: {
// id: 1
// }
// }
const roleName = "admin";
const { updateRole } = await m(`
updateRole(id: ${id}, data: {
name: ${roleName}
}) {
id
name
}
`);
// updateRole variable can look like this:
// {
// id: 1,
// name: 'admin'
// }
})();
Providing custom headers.
import { setHeaders } from "graphoon";
setHeaders({
authorization: "bearer my_sweet_sweet_token",
another_header: "another_value"
});
Method setHeaders changes configuration permanently for every query/mutation that will be called after calling this methods.
So if you need, for example, customize your queries with some AUTH data, you can use setHeaders method only once.
Changing endpoind url from default /graphql to anything else.
import { setUri } from "graphoon";
setUri("/my_sweet_endpoint");
Methods setUri changes configuration permanently for every query/mutation that will be called after calling this methods.
So if you need, for example, change your endpoint from /graphql to /gql you can use setUri method only once.
You can use trycatch to handle errors that occure inside GraphQL body.
All error messages will be enumerated via ; symbol.
import { query } from "graphoon";
(async function() {
try {
const id = 10;
const { profiles } = await q(`
profiles(userId: ${id}) {
id
type
active
}
`);
} catch (error) {
console.error(error.message);
}
})();
You can use methods q and m to work with promises.
import { q, m } from "graphoon";
const id = 10;
q(`profiles(userId: ${id}) {
id
type
active
}`)
.then(({ profiles }) => {
// work with profiles here
})
.catch(error => {
console.error(error.message);
});
const roleName = "admin";
m(`updateRole(id: ${id}, data: {
name: ${roleName}
}) {
id
name
}`)
.then(({ updateRole }) => {
// work with updated role here
})
.catch(error => {
console.error(error.message);
});
FAQs
Easy GraphQL client
We found that graphoon 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.