GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - directionless/github-graphql-experiments: Experiments with the github graphql api

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
fetch-team-members-v3.py
fetch-team-members-v3.py
 
 
fetch-team-members-v4.py
fetch-team-members-v4.py
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

GitHub GraphQL Experiments

This repository accompanies an unwritten blog post

Introduction

Recently, I was writing some scripts to audit and sync a github organization with an external list of users. GitHub recently changed their API over to graphql, so I thought it would be a fun time to experiment.

The simplest way to do this with the REST api, is a trivial for loop -- for each team, fetch the team info. A trivial implementation is at fetch-team-members-v3.py.

But, this has a lot of overhead. It's a REST call per team, and each call has a bunch of extraneous data. So, can we use graphql?

As it turns out, yes. But it took me awhile to work through the pagination.

Early Experiments

FIXME: Add content here

Final Realization

Ultimately, I realized that the correct way to handle the inner pagination was something akin to recursion. Fetch as much data as we can, and for anything incomplete, come back and fill in the details. Whether this is done inline, or as a second step doesn't matter much.

This results in something much more efficient. We're able to query for most of the teams, and most of their members with a single API call. And the few that require pagination can be followed up.

Proof of concept code can be see at fetch-team-members-v4.py.

About

Experiments with the github graphql api

Resources

Readme
Apache-2.0 license
Activity

Stars

3 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.