Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@github-graph/api
Advanced tools
API client for GitHub's GraphQL API that automatically merges multiple requests into one where possible, saving you from hitting the API rate limits.
API client for GitHub's GraphQL API that automatically merges multiple requests into one where possible, saving you from hitting the API rate limits.
yarn add @github-graph/api
import Client, {auth, gql, getMethod} from '@github-graph/api';
const getStargazers = getMethod<
{repository: {nameWithOwner: string; stargazers: {totalCount: number}}},
{owner: string; name: string}
>(gql`
query GetStargazers($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
nameWithOwner
stargazers {
totalCount
}
}
}
`);
const getWatchers = getMethod<
{repository: {nameWithOwner: string; watchers: {totalCount: number}}},
{owner: string; name: string}
>(gql`
query GetWatchers($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
nameWithOwner
watchers {
totalCount
}
}
}
`);
const client = new Client({
auth: auth.createTokenAuth(GITHUB_TOKEN),
});
await Promise.all([
getStargazers(client, {owner: 'pugjs', name: 'pug'}),
getWatchers(client, {owner: 'pugjs', name: 'pug'})),
getStargazers(client, {owner: 'ForbesLindesay', name: 'atdatabases'}),
getWatchers(client, {owner: 'ForbesLindesay', name: 'atdatabases'}),
]);
Unlike other libraries, that would send 4 separate queries to the backend. This library will only send one:
{
query: `
query ($owner: String!, $name: String!, $b: String!, $c: String!) {
repository(owner: $owner, name: $name) {
nameWithOwner
stargazers {
totalCount
}
watchers {
totalCount
}
}
b: repository(owner: $b, name: $c) {
nameWithOwner
stargazers {
totalCount
}
watchers {
totalCount
}
}
}
`,
variables: {
b: 'ForbesLindesay',
c: 'atdatabases',
name: 'pug',
owner: 'pugjs',
},
}
This is 4 times fewer tokens used from your rate limit.
Unfortunatley not everything on GitHub is available via the GraphQL API. If you need to, you can use client.rest
which matches the octokit/rest API. or you can use client.request
which lets you make direct un-typed requests to the GitHub API.
If you already have an octokit client, you can construct a github-graph client via:
const client = new Client({
request: octokitClient.request,
});
FAQs
API client for GitHub's GraphQL API that automatically merges multiple requests into one where possible, saving you from hitting the API rate limits.
The npm package @github-graph/api receives a total of 15 weekly downloads. As such, @github-graph/api popularity was classified as not popular.
We found that @github-graph/api 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.