Last active
October 14, 2019 02:00
-
-
Save Vultraz/ae3f451a7d9a981eaac6435bea5ee8f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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