Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Created April 5, 2020 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save toolmantim/fc39dc21e8ca58baa3cb954049ae675c to your computer and use it in GitHub Desktop.
Save toolmantim/fc39dc21e8ca58baa3cb954049ae675c to your computer and use it in GitHub Desktop.
fetch('https://api.github.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.GITHUB_API_TOKEN}`
},
body: JSON.stringify({ query: query() })
})
.then((res) => res.json())
.then((data) => {
console.log(JSON.stringify(data));
return data
})
.then((data) => {
return processResults(data)
})
.catch((err) => {
console.error(err)
process.exit(1)
})
function query() {
return `
query {
search(query:"topic:buildkite-plugin", first: 100, type:REPOSITORY) {
repositoryCount
nodes {
...on Repository {
createdAt
name
stargazers {
totalCount
}
owner {
login
avatarUrl
}
object(expression:"master:plugin.yml") {
... on Blob{
text
}
}
repositoryTopics(first: 10) {
nodes {
topic {
name
}
}
}
releases(first: 1, orderBy: {field:NAME, direction:DESC}) {
nodes {
publishedAt
tag {
name
target {
oid
}
}
}
}
refs(refPrefix: "refs/tags/", first: 1, orderBy: {field:ALPHABETICAL, direction:DESC}) {
nodes {
name
target {
... on Commit {
pushedDate
}
}
}
}
pushedAt
}
}
}
}
`
}
function processResults(data) {
return { foo: "bar" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment