Skip to content

Instantly share code, notes, and snippets.

@Vultraz
Last active October 14, 2019 02:00
Show Gist options
  • Save Vultraz/ae3f451a7d9a981eaac6435bea5ee8f1 to your computer and use it in GitHub Desktop.
Save Vultraz/ae3f451a7d9a981eaac6435bea5ee8f1 to your computer and use it in GitHub Desktop.
//
// Implementaiton borrowed from https://dev.to/thomasaudo/get-started-with-github-grapql-api--1g8b
//
require('dotenv-safe').config();
const Axios = require('axios');
const endpt = 'https://api.github.com/graphql';
const oauth = { Authorization: `bearer ${process.env.AUTH_TOKEN}`};
const tagDateQuery = `
query getTagDate {
repository(owner: "wesnoth", name: "wesnoth") {
refs(refPrefix: "refs/tags/", first: 1, orderBy: {direction: DESC, field: TAG_COMMIT_DATE}) {
nodes {
target {
... on Tag {
tagger {
date
}
}
}
}
}
}
}
`;
const run = async () => {
try {
const res = await Axios.post(endpt, { query: tagDateQuery }, { headers: oauth });
console.log(res.data.data.repository.refs.nodes[0].target.tagger.date);
} catch(error) {
console.log(error);
}
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment