From 7d0a0866c7f892b57f751af26cfc21ba1a8dfe4d Mon Sep 17 00:00:00 2001 From: mjgaughan Date: Wed, 25 Oct 2023 23:38:14 -0500 Subject: [PATCH] trying to figure out gh graphql schema --- github_api_req.py | 17 +++++++++++++++++ request.json | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 request.json diff --git a/github_api_req.py b/github_api_req.py index fcf0d0c..536a163 100644 --- a/github_api_req.py +++ b/github_api_req.py @@ -1,5 +1,9 @@ import requests import datetime as dt +import json +import os + +key = os.environ.get('KKEXKEY') def main(vcs, begin_date): repo_uri=vcs[0] @@ -30,6 +34,19 @@ def parse_milestones(milestones, earliest_date): count_of_milestones += 1 return count_of_milestones + +def get_discussion_gql(): + #testing + url = "https://api.github.com/graphql" + x = {"query" : "query { repository(owner: 'beekeeper-studio', name: 'beekeeper-studio') { discussions(first: 10) {totalCount}}"} + data = json.dumps(x) + headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Authorization': 'bearer ' + key} + r = requests.post(url=url, data=data, headers=headers) + print(r.content) + print(r.json()) + +if __name__ == "__main__": + get_discussion_gql() ''' #using the github API to identify who is a collaborator on the project and who is just a contributor def split_actors(repo_uri, actors_list): diff --git a/request.json b/request.json new file mode 100644 index 0000000..ebd058f --- /dev/null +++ b/request.json @@ -0,0 +1,33 @@ +{ + query { + repository(owner: "github", name: "some-repo") { + discussions(first: 10) { + # type: DiscussionConnection + totalCount # Int! + + pageInfo { + # type: PageInfo (from the public schema) + startCursor + endCursor + hasNextPage + hasPreviousPage + } + + edges { + # type: DiscussionEdge + cursor + node { + # type: Discussion + id + } + } + + nodes { + # type: Discussion + id + } + } + } + } +} + \ No newline at end of file