Skip to content

Instantly share code, notes, and snippets.

@sorenlouv
Created August 26, 2022 08:22
Show Gist options
  • Save sorenlouv/9667876b6e925c41b4d66fe6cfdbfdc0 to your computer and use it in GitHub Desktop.
Save sorenlouv/9667876b6e925c41b4d66fe6cfdbfdc0 to your computer and use it in GitHub Desktop.
Example of a graphql query
query CommitsByAuthor($authorId: ID, $commitPath: String, $dateSince: GitTimestamp, $dateUntil: GitTimestamp, $maxNumber: Int!, $repoName: String!, $repoOwner: String!, $sourceBranch: String!) {
repository(owner: $repoOwner, name: $repoName) {
ref(qualifiedName: $sourceBranch) {
target {
... on Commit {
history(first: $maxNumber, author: {id: $authorId}, path: $commitPath, since: $dateSince, until: $dateUntil) {
edges {
node {
...SourceCommitWithTargetPullRequestFragment
}
}
}
}
}
}
}
}
fragment SourceCommitWithTargetPullRequestFragment on Commit {
repository {
name
owner {
login
}
}
sha: oid
message
committedDate
author {
name
email
}
associatedPullRequests(first: 1) {
edges {
node {
url
number
labels(first: 50) {
nodes {
name
}
}
baseRefName
mergeCommit {
...RemoteConfigHistoryFragment
sha: oid
message
}
timelineItems(last: 20, itemTypes: CROSS_REFERENCED_EVENT) {
edges {
node {
... on CrossReferencedEvent {
targetPullRequest: source {
__typename
... on PullRequest {
targetMergeCommit: mergeCommit {
sha: oid
message
}
repository {
name
owner {
login
}
}
url
title
state
baseRefName
number
commits(first: 20) {
edges {
node {
targetCommit: commit {
message
sha: oid
}
}
}
}
}
}
}
}
}
}
}
}
}
}
fragment RemoteConfigHistoryFragment on Commit {
remoteConfigHistory: history(first: 1, path: ".backportrc.json") {
edges {
remoteConfig: node {
committedDate
file(path: ".backportrc.json") {
... on TreeEntry {
object {
... on Blob {
text
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment