Skip to content

Instantly share code, notes, and snippets.

@mikegrima
Last active November 23, 2022 23:38
Show Gist options
  • Save mikegrima/bb2643a18f657d1e4d12e51bafb54b41 to your computer and use it in GitHub Desktop.
Save mikegrima/bb2643a18f657d1e4d12e51bafb54b41 to your computer and use it in GitHub Desktop.
GitHub GraphQL Queries

GitHub GraphQL is annoying AF.

These are some sample queries that I have needed to do and am logging it here so I don't forget them.

API endpoint: https://api.github.com/graphql, Method: POST. Authorization requires a Bearer token, and apparently: Personal access tokens with fine grained access do not support the GraphQL API... So that's lame! (as of November 2022)

# Fetch the newest tag for a repo:
{
repository(owner: "ORG_NAME", name: "REPO_NAME") {
refs(refPrefix: "refs/tags/", orderBy: {field: TAG_COMMIT_DATE, direction: DESC}, first: 1) {
edges {
node {
name
}
}
}
}
}
# Fetch a user's SCIM username (I.e. their IDP email address) from their GitHub ID (for Orgs integrated with SAML):
{
organization(login: "ORG_NAME") {
samlIdentityProvider {
externalIdentities(login: "GITHUB_USERNAME", first: 1) {
nodes {
scimIdentity {
username
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment