Skip to content

Instantly share code, notes, and snippets.

@envygeeks
Last active March 8, 2019 06:59
Show Gist options
  • Save envygeeks/39475f29ce293f19c328066bacd3b139 to your computer and use it in GitHub Desktop.
Save envygeeks/39475f29ce293f19c328066bacd3b139 to your computer and use it in GitHub Desktop.
Github API GraphQL
fragment UserFields on User { url, name, avatarUrl, login }
fragment PageInfoFields on PageInfo { startCursor, hasPreviousPage, hasNextPage, endCursor }
fragment OrganizationFields on Organization { url, org: name , avatarUrl, login }
fragment RateLimitFields on RateLimit { resetAt, remaining, limit, cost }
fragment RepositoryFields on Repository {
pushedAt
nameWithOwner
hasIssuesEnabled
hasWikiEnabled
name
url
owner {
... on Organization { ...OrganizationFields }
... on User {
...UserFields
}
}
primaryLanguage { name }
pullRequests(states: OPEN) { totalCount }
issues(states: OPEN) { totalCount }
stargazers { totalCount }
forks { totalCount }
}
fragment CommitFields on Commit {
abbreviatedOid
messageHeadline
commitUrl
oid
author {
user {
...UserFields
}
}
}
query Limit {
rateLimit {
...RateLimitFields
}
}
query Repos($count: Int!, $user: String!,
$after: String, $order: RepositoryOrderField = STARGAZERS,
$privacy: RepositoryPrivacy = PUBLIC) {
rateLimit {
...RateLimitFields
}
user(login: $user) {
repositories(privacy: $privacy, first: $count, isFork: false,
affiliations: [OWNER, COLLABORATOR, ORGANIZATION_MEMBER], orderBy: {
field: $order, direction: DESC }, after: $after) {
pageInfo {
...PageInfoFields
}
edges {
node {
...RepositoryFields
}
}
}
}
}
query Repo($repo: String!, $user: String!, $count: Int!) {
rateLimit {
...RateLimitFields
}
repository(owner: $user, name: $repo) {
...RepositoryFields
ref(qualifiedName: "refs/heads/master") {
target {
... on Commit {
id
history(first: $count) {
edges {
node {
...CommitFields
}
}
}
}
}
}
}
}
query Stat($repo: String!, $user: String!, $after: String,
$path: String!, $count: Int!) {
rateLimit {
...RateLimitFields
}
repository(owner: $user, name: $repo) {
ref(qualifiedName: "refs/heads/master") {
target {
... on Commit {
history(first: $count, path: $path, after: $after) {
pageInfo {
...PageInfoFields
}
edges {
node {
...CommitFields
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment