From 6f8b13d5661d22daec7003fcbd82430841b44dcd Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Thu, 7 Sep 2017 13:06:02 -0400 Subject: [PATCH 01/11] github: add skeleton Github implementation --- Cargo.toml | 5 ++++- ghostflow-github/Cargo.toml | 13 +++++++++++++ ghostflow-github/README.md | 5 +++++ ghostflow-github/src/lib.rs | 7 +++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 ghostflow-github/Cargo.toml create mode 100644 ghostflow-github/README.md create mode 100644 ghostflow-github/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index d8660383..dcd3f26b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,10 @@ readme = "README.md" keywords = ["git", "workflow", "ghostflow"] [workspace] -members = ["ghostflow-gitlab"] +members = [ + "ghostflow-github", + "ghostflow-gitlab", +] [dependencies] either = "^1.0" diff --git a/ghostflow-github/Cargo.toml b/ghostflow-github/Cargo.toml new file mode 100644 index 00000000..2dbcb742 --- /dev/null +++ b/ghostflow-github/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "ghostflow-github" +version = "0.1.0" +authors = ["Ben Boeckel <ben.boeckel@kitware.com>"] +license = "MIT/Apache-2.0" +description = """ +Implementation of ghostflow traits for GitHub. +""" +workspace = ".." +repository = "https://gitlab.kitware.com/utils/rust-ghostflow" +documentation = "https://docs.rs/ghostflow-github/~0.1" +readme = "README.md" +keywords = ["git", "workflow", "ghostflow", "github"] diff --git a/ghostflow-github/README.md b/ghostflow-github/README.md new file mode 100644 index 00000000..cd61f154 --- /dev/null +++ b/ghostflow-github/README.md @@ -0,0 +1,5 @@ +# ghostflow-github + +This crate implements the host traits for the [GitHub][] hosting service. + +[GitHub]: https://github.com diff --git a/ghostflow-github/src/lib.rs b/ghostflow-github/src/lib.rs new file mode 100644 index 00000000..e15a4f06 --- /dev/null +++ b/ghostflow-github/src/lib.rs @@ -0,0 +1,7 @@ +// Copyright 2016 Kitware, Inc. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. -- GitLab From d9f0cc9a7645e7d5eae62f6bf3794f1456f92b6e Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Fri, 7 Sep 2018 13:40:14 -0400 Subject: [PATCH 02/11] graphql: add a way to update the github graphql schema --- ghostflow-github/src/graphql/.gitignore | 1 + ghostflow-github/src/graphql/update_schema.sh | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 ghostflow-github/src/graphql/.gitignore create mode 100755 ghostflow-github/src/graphql/update_schema.sh diff --git a/ghostflow-github/src/graphql/.gitignore b/ghostflow-github/src/graphql/.gitignore new file mode 100644 index 00000000..d23bcc7f --- /dev/null +++ b/ghostflow-github/src/graphql/.gitignore @@ -0,0 +1 @@ +.gh-token diff --git a/ghostflow-github/src/graphql/update_schema.sh b/ghostflow-github/src/graphql/update_schema.sh new file mode 100755 index 00000000..5bb52504 --- /dev/null +++ b/ghostflow-github/src/graphql/update_schema.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +readonly token="$( cat ".gh-token" )" + +curl \ + --header "Accept: application/vnd.github.antiope-preview+json" \ + --header "Accept: application/vnd.github.cateye-preview+json" \ + --header "Accept: application/vnd.github.starfire-preview+json" \ + --header "Accept: application/vnd.github.v4.idl" \ + --header "Authorization: bearer $token" \ + "https://api.github.com/graphql" | \ + jq .data --raw-output \ + > schema.graphql + +# Double newline because the main schema is without a newline at the end of the +# file. +cat >>schema.graphql <<EOF + +schema { + query: Query + mutation: Mutation +} +EOF -- GitLab From 37eadea63b44de99dc39b682601b947b098effc1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Fri, 7 Sep 2018 13:41:30 -0400 Subject: [PATCH 03/11] graphql: commit the github schema --- ghostflow-github/src/graphql/.gitattributes | 2 + ghostflow-github/src/graphql/schema.graphql | 10238 ++++++++++++++++++ 2 files changed, 10240 insertions(+) create mode 100644 ghostflow-github/src/graphql/.gitattributes create mode 100644 ghostflow-github/src/graphql/schema.graphql diff --git a/ghostflow-github/src/graphql/.gitattributes b/ghostflow-github/src/graphql/.gitattributes new file mode 100644 index 00000000..8569ce29 --- /dev/null +++ b/ghostflow-github/src/graphql/.gitattributes @@ -0,0 +1,2 @@ +# This file is downloaded from GitHub. Ignore any whitespace errors in it. +schema.graphql -whitespace diff --git a/ghostflow-github/src/graphql/schema.graphql b/ghostflow-github/src/graphql/schema.graphql new file mode 100644 index 00000000..1c924a98 --- /dev/null +++ b/ghostflow-github/src/graphql/schema.graphql @@ -0,0 +1,10238 @@ +# Autogenerated input type of AcceptTopicSuggestion +input AcceptTopicSuggestionInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of the suggested topic. + name: String! + + # The Node ID of the repository. + repositoryId: ID! +} + +# Autogenerated return type of AcceptTopicSuggestion +type AcceptTopicSuggestionPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The accepted topic. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `topic` will change from `Topic!` to `Topic`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + topic: Topic! +} + +# Represents an object which can take actions on GitHub. Typically a User or Bot. +interface Actor { + # A URL pointing to the actor's public avatar. + avatarUrl( + # The size of the resulting square image. + size: Int + ): URI! + + # The username of the actor. + login: String! + + # The HTTP path for this actor. + resourcePath: URI! + + # The HTTP URL for this actor. + url: URI! +} + +# Autogenerated input type of AddAssigneesToAssignable +input AddAssigneesToAssignableInput { + # The id of the assignable object to add assignees to. + assignableId: ID! + + # The id of users to add as assignees. + assigneeIds: [ID!]! + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated return type of AddAssigneesToAssignable +type AddAssigneesToAssignablePayload { + # The item that was assigned. + assignable: Assignable + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of AddComment +input AddCommentInput { + # The contents of the comment. + body: String! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the subject to modify. + subjectId: ID! +} + +# Autogenerated return type of AddComment +type AddCommentPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The edge from the subject's comment connection. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `commentEdge` will change from `IssueCommentEdge!` to `IssueCommentEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + commentEdge: IssueCommentEdge! + + # The subject + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `subject` will change from `Node!` to `Node`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + subject: Node! + + # The edge from the subject's timeline connection. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `timelineEdge` will change from `IssueTimelineItemEdge!` to `IssueTimelineItemEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + timelineEdge: IssueTimelineItemEdge! +} + +# Autogenerated input type of AddLabelsToLabelable +input AddLabelsToLabelableInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ids of the labels to add. + labelIds: [ID!]! + + # The id of the labelable object to add labels to. + labelableId: ID! +} + +# Autogenerated return type of AddLabelsToLabelable +type AddLabelsToLabelablePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The item that was labeled. + labelable: Labelable +} + +# Autogenerated input type of AddProjectCard +input AddProjectCardInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The content of the card. Must be a member of the ProjectCardItem union + contentId: ID + + # The note on the card. + note: String + + # The Node ID of the ProjectColumn. + projectColumnId: ID! +} + +# Autogenerated return type of AddProjectCard +type AddProjectCardPayload { + # The edge from the ProjectColumn's card connection. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `cardEdge` will change from `ProjectCardEdge!` to `ProjectCardEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + cardEdge: ProjectCardEdge! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ProjectColumn + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `projectColumn` will change from `Project!` to `Project`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + projectColumn: Project! +} + +# Autogenerated input type of AddProjectColumn +input AddProjectColumnInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of the column. + name: String! + + # The Node ID of the project. + projectId: ID! +} + +# Autogenerated return type of AddProjectColumn +type AddProjectColumnPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The edge from the project's column connection. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `columnEdge` will change from `ProjectColumnEdge!` to `ProjectColumnEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + columnEdge: ProjectColumnEdge! + + # The project + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `project` will change from `Project!` to `Project`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + project: Project! +} + +# Autogenerated input type of AddPullRequestReviewComment +input AddPullRequestReviewCommentInput { + # The text of the comment. + body: String! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The SHA of the commit to comment on. + commitOID: GitObjectID + + # The comment id to reply to. + inReplyTo: ID + + # The relative path of the file to comment on. + path: String + + # The line index in the diff to comment on. + position: Int + + # The Node ID of the review to modify. + pullRequestReviewId: ID! +} + +# Autogenerated return type of AddPullRequestReviewComment +type AddPullRequestReviewCommentPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The newly created comment. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `comment` will change from `PullRequestReviewComment!` to `PullRequestReviewComment`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + comment: PullRequestReviewComment! + + # The edge from the review's comment connection. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `commentEdge` will change from + # `PullRequestReviewCommentEdge!` to `PullRequestReviewCommentEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + commentEdge: PullRequestReviewCommentEdge! +} + +# Autogenerated input type of AddPullRequestReview +input AddPullRequestReviewInput { + # The contents of the review body comment. + body: String + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The review line comments. + comments: [DraftPullRequestReviewComment] + + # The commit OID the review pertains to. + commitOID: GitObjectID + + # The event to perform on the pull request review. + event: PullRequestReviewEvent + + # The Node ID of the pull request to modify. + pullRequestId: ID! +} + +# Autogenerated return type of AddPullRequestReview +type AddPullRequestReviewPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The newly created pull request review. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequestReview` will change from `PullRequestReview!` to `PullRequestReview`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequestReview: PullRequestReview! + + # The edge from the pull request's review connection. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `reviewEdge` will change from `PullRequestReviewEdge!` to `PullRequestReviewEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + reviewEdge: PullRequestReviewEdge! +} + +# Autogenerated input type of AddReaction +input AddReactionInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of the emoji to react with. + content: ReactionContent! + + # The Node ID of the subject to modify. + subjectId: ID! +} + +# Autogenerated return type of AddReaction +type AddReactionPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The reaction object. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `reaction` will change from `Reaction!` to `Reaction`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + reaction: Reaction! + + # The reactable subject. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `subject` will change from `Reactable!` to `Reactable`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + subject: Reactable! +} + +# Autogenerated input type of AddStar +input AddStarInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Starrable ID to star. + starrableId: ID! +} + +# Autogenerated return type of AddStar +type AddStarPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The starrable. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `starrable` will change from `Starrable!` to `Starrable`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + starrable: Starrable! +} + +# Represents a 'added_to_project' event on a given issue or pull request. +type AddedToProjectEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# A GitHub App. +type App implements Node { + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + + # The description of the app. + description: String + id: ID! + + # The hex color code, without the leading '#', for the logo background. + logoBackgroundColor: String! + + # A URL pointing to the app's logo. + logoUrl( + # The size of the resulting image. + size: Int + ): URI! + + # The name of the app. + name: String! + + # A slug based on the name of the app for use in URLs. + slug: String! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The URL to the app's homepage. + url: URI! +} + +# An edge in a connection. +type AppEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: App +} + +# An object that can have users assigned to it. +interface Assignable { + # A list of Users assigned to this object. + assignees( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! +} + +# Represents an 'assigned' event on any assignable object. +type AssignedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the assignable associated with the event. + assignable: Assignable! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the user who was assigned. + user: User +} + +# Represents a 'base_ref_changed' event on a given issue or pull request. +type BaseRefChangedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# Represents a 'base_ref_force_pushed' event on a given pull request. +type BaseRefForcePushedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the after commit SHA for the 'base_ref_force_pushed' event. + afterCommit: Commit + + # Identifies the before commit SHA for the 'base_ref_force_pushed' event. + beforeCommit: Commit + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # Identifies the fully qualified ref name for the 'base_ref_force_pushed' event. + ref: Ref +} + +# Represents a Git blame. +type Blame { + # The list of ranges from a Git blame. + ranges: [BlameRange!]! +} + +# Represents a range of information from a Git blame. +type BlameRange { + # Identifies the recency of the change, from 1 (new) to 10 (old). This is + # calculated as a 2-quantile and determines the length of distance between the + # median age of all the changes in the file and the recency of the current + # range's change. + age: Int! + + # Identifies the line author + commit: Commit! + + # The ending line for the range + endingLine: Int! + + # The starting line for the range + startingLine: Int! +} + +# Represents a Git blob. +type Blob implements GitObject & Node { + # An abbreviated version of the Git object ID + abbreviatedOid: String! + + # Byte size of Blob object + byteSize: Int! + + # The HTTP path for this Git object + commitResourcePath: URI! + + # The HTTP URL for this Git object + commitUrl: URI! + id: ID! + + # Indicates whether the Blob is binary or text + isBinary: Boolean! + + # Indicates whether the contents is truncated + isTruncated: Boolean! + + # The Git object ID + oid: GitObjectID! + + # The Repository the Git object belongs to + repository: Repository! + + # UTF8 text data or null if the Blob is binary + text: String +} + +# A special type of user which takes actions on behalf of GitHub Apps. +type Bot implements Actor & Node & UniformResourceLocatable { + # A URL pointing to the GitHub App's public avatar. + avatarUrl( + # The size of the resulting square image. + size: Int + ): URI! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # The username of the actor. + login: String! + + # The HTTP path for this bot + resourcePath: URI! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this bot + url: URI! +} + +# A single check annotation. +type CheckAnnotation { + # The annotation's severity level. + annotationLevel: CheckAnnotationLevel + + # The path to the file that this annotation was made on. + blobUrl: URI! + + # Identifies the primary key from the database. + databaseId: Int + + # The position of this annotation. + location: CheckAnnotationSpan! + + # The annotation's message. + message: String! + + # The path that this annotation was made on. + path: String! + + # Additional information about the annotation. + rawDetails: String + + # The annotation's title + title: String +} + +# The connection type for CheckAnnotation. +type CheckAnnotationConnection { + # A list of edges. + edges: [CheckAnnotationEdge] + + # A list of nodes. + nodes: [CheckAnnotation] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Information from a check run analysis to specific lines of code. +input CheckAnnotationData { + # Represents an annotation's information level + annotationLevel: CheckAnnotationLevel! + + # The location of the annotation + location: CheckAnnotationRange! + + # A short description of the feedback for these lines of code. + message: String! + + # The path of the file to add an annotation to. + path: String! + + # Details about this annotation. + rawDetails: String + + # The title that represents the annotation. + title: String +} + +# An edge in a connection. +type CheckAnnotationEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: CheckAnnotation +} + +# Represents an annotation's information level. +enum CheckAnnotationLevel { + # An annotation indicating an inescapable error. + FAILURE + + # An annotation indicating some information. + NOTICE + + # An annotation indicating an ignorable error. + WARNING +} + +# A character position in a check annotation. +type CheckAnnotationPosition { + # Column number (1 indexed). + column: Int + + # Line number (1 indexed). + line: Int! +} + +# Information from a check run analysis to specific lines of code. +input CheckAnnotationRange { + # The ending column of the range. + endColumn: Int + + # The ending line of the range. + endLine: Int! + + # The starting column of the range. + startColumn: Int + + # The starting line of the range. + startLine: Int! +} + +# An inclusive pair of positions for a check annotation. +type CheckAnnotationSpan { + # End position (inclusive). + end: CheckAnnotationPosition! + + # Start position (inclusive). + start: CheckAnnotationPosition! +} + +# The possible states for a check suite or run conclusion. +enum CheckConclusionState { + # The check suite or run requires action. + ACTION_REQUIRED + + # The check suite or run has been cancelled. + CANCELLED + + # The check suite or run has failed. + FAILURE + + # The check suite or run was neutral. + NEUTRAL + + # The check suite or run has succeeded. + SUCCESS + + # The check suite or run has timed out. + TIMED_OUT +} + +# A check run. +type CheckRun implements Node & UniformResourceLocatable { + # The check run's annotations + annotations( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CheckAnnotationConnection + + # The check suite that this run is a part of. + checkSuite: CheckSuite! + + # Identifies the date and time when the check run was completed. + completedAt: DateTime + + # The conclusion of the check run. + conclusion: CheckConclusionState + + # Identifies the primary key from the database. + databaseId: Int + + # The URL from which to find full details of the check run on the integrator's site. + detailsUrl: URI + + # A reference for the check run on the integrator's system. + externalId: String + id: ID! + + # The name of the check for this check run. + name: String! + + # The permalink to the check run summary. + permalink: URI! + + # The repository associated with this check run. + repository: Repository! + + # The HTTP path for this check run. + resourcePath: URI! + + # Identifies the date and time when the check run was started. + startedAt: DateTime + + # The current status of the check run. + status: CheckStatusState! + + # A string representing the check run's summary + summary: String + + # A string representing the check run's text + text: String + + # A string representing the check run + title: String + + # The HTTP URL for this check run. + url: URI! +} + +# Possible further actions the integrator can perform. +input CheckRunAction { + # A short explanation of what this action would do. + description: String! + + # A reference for the action on the integrator's system. + identifier: String! + + # The text to be displayed on a button in the web UI. + label: String! +} + +# The connection type for CheckRun. +type CheckRunConnection { + # A list of edges. + edges: [CheckRunEdge] + + # A list of nodes. + nodes: [CheckRun] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type CheckRunEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: CheckRun +} + +# The filters that are available when fetching check runs. +input CheckRunFilter { + # Filters the check runs created by this application ID. + appId: Int + + # Filters the check runs by this name. + checkName: String + + # Filters the check runs by this type. + checkType: CheckRunType + + # Filters the check runs by this status. + status: CheckStatusState +} + +# Descriptive details about the check run. +input CheckRunOutput { + # The annotations that are made as part of the check run. + annotations: [CheckAnnotationData!] + + # Images attached to the check run output displayed in the GitHub pull request UI. + images: [CheckRunOutputImage!] + + # The summary of the check run (supports Commonmark). + summary: String! + + # The details of the check run (supports Commonmark). + text: String + + # A title to provide for this check run. + title: String! +} + +# Images attached to the check run output displayed in the GitHub pull request UI. +input CheckRunOutputImage { + # The alternative text for the image. + alt: String! + + # A short image description. + caption: String + + # The full URL of the image. + imageUrl: URI! +} + +# The possible types of check runs. +enum CheckRunType { + # Every check run available. + ALL + + # The latest check run. + LATEST +} + +# The possible states for a check suite or run status. +enum CheckStatusState { + # The check suite or run has been completed. + COMPLETED + + # The check suite or run is in progress. + IN_PROGRESS + + # The check suite or run has been queued. + QUEUED + + # The check suite or run has been requested. + REQUESTED +} + +# A check suite. +type CheckSuite implements Node { + # The name of the branch for this check suite. + branch: Ref + + # The check runs associated with a check suite. + checkRuns( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Filters the check runs by this type. + filterBy: CheckRunFilter + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CheckRunConnection + + # The commit for this check suite + commit: Commit! + + # The conclusion of this check suite. + conclusion: CheckConclusionState + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # A list of open pull requests matching the check suite. + matchingPullRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # The base ref name to filter the pull requests by. + baseRefName: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # The head ref name to filter the pull requests by. + headRefName: String + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for pull requests returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the pull requests by. + states: [PullRequestState!] + ): PullRequestConnection + + # The push that triggered this check suite. + push: Push + + # The repository associated with this check suite. + repository: Repository! + + # The status of this check suite. + status: CheckStatusState! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! +} + +# The auto-trigger preferences that are available for check suites. +input CheckSuiteAutoTriggerPreference { + # The node ID of the application that owns the check suite. + appId: ID! + + # Set to `true` to enable automatic creation of CheckSuite events upon pushes to the repository. + setting: Boolean! +} + +# The connection type for CheckSuite. +type CheckSuiteConnection { + # A list of edges. + edges: [CheckSuiteEdge] + + # A list of nodes. + nodes: [CheckSuite] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type CheckSuiteEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: CheckSuite +} + +# The filters that are available when fetching check suites. +input CheckSuiteFilter { + # Filters the check suites created by this application ID. + appId: Int + + # Filters the check suites by this name. + checkName: String +} + +# Autogenerated input type of ClearLabelsFromLabelable +input ClearLabelsFromLabelableInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The id of the labelable object to clear the labels from. + labelableId: ID! +} + +# Autogenerated return type of ClearLabelsFromLabelable +type ClearLabelsFromLabelablePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The item that was unlabeled. + labelable: Labelable +} + +# An object that can be closed +interface Closable { + # `true` if the object is closed (definition of closed may depend on type) + closed: Boolean! + + # Identifies the date and time when the object was closed. + closedAt: DateTime +} + +# Autogenerated input type of CloseIssue +input CloseIssueInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # ID of the issue to be closed. + issueId: ID! +} + +# Autogenerated return type of CloseIssue +type CloseIssuePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The issue that was closed. + issue: Issue +} + +# Represents a 'closed' event on any `Closable`. +type ClosedEvent implements Node & UniformResourceLocatable { + # Identifies the actor who performed the event. + actor: Actor + + # Object that was closed. + closable: Closable! + + # Object which triggered the creation of this event. + closer: Closer + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # The HTTP path for this closed event. + resourcePath: URI! + + # The HTTP URL for this closed event. + url: URI! +} + +# The object which triggered a `ClosedEvent`. +union Closer = Commit | PullRequest + +# The Code of Conduct for a repository +type CodeOfConduct { + # The body of the CoC + body: String + + # The key for the CoC + key: String! + + # The formal name of the CoC + name: String! + + # The path to the CoC + url: URI +} + +# Collaborators affiliation level with a subject. +enum CollaboratorAffiliation { + # All collaborators the authenticated user can see. + ALL + + # All collaborators with permissions to an organization-owned subject, regardless of organization membership status. + DIRECT + + # All outside collaborators of an organization-owned subject. + OUTSIDE +} + +# Types that can be inside Collection Items. +union CollectionItemContent = Organization | Repository | User + +# Represents a comment. +interface Comment { + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # The body as Markdown. + body: String! + + # The body rendered to HTML. + bodyHTML: HTML! + + # The body rendered to text. + bodyText: String! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # The actor who edited the comment. + editor: Actor + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # Identifies when the comment was published at. + publishedAt: DateTime + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! +} + +# A comment author association with repository. +enum CommentAuthorAssociation { + # Author has been invited to collaborate on the repository. + COLLABORATOR + + # Author has previously committed to the repository. + CONTRIBUTOR + + # Author has not previously committed to GitHub. + FIRST_TIMER + + # Author has not previously committed to the repository. + FIRST_TIME_CONTRIBUTOR + + # Author is a member of the organization that owns the repository. + MEMBER + + # Author has no association with the repository. + NONE + + # Author is the owner of the repository. + OWNER +} + +# The possible errors that will prevent a user from updating a comment. +enum CommentCannotUpdateReason { + # You must be the author or have write access to this repository to update this comment. + INSUFFICIENT_ACCESS + + # Unable to create comment because issue is locked. + LOCKED + + # You must be logged in to update this comment. + LOGIN_REQUIRED + + # Repository is under maintenance. + MAINTENANCE + + # At least one email address must be verified to update this comment. + VERIFIED_EMAIL_REQUIRED +} + +# Represents a 'comment_deleted' event on a given issue or pull request. +type CommentDeletedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# Represents a Git commit. +type Commit implements GitObject & Node & Subscribable { + # An abbreviated version of the Git object ID + abbreviatedOid: String! + + # The number of additions in this commit. + additions: Int! + + # Authorship details of the commit. + author: GitActor + + # Check if the committer and the author match. + authoredByCommitter: Boolean! + + # The datetime when this commit was authored. + authoredDate: DateTime! + + # Fetches `git blame` information. + blame( + # The file whose Git blame information you want. + path: String! + ): Blame! + + # The number of changed files in this commit. + changedFiles: Int! + + # The check suites associated with a commit. + checkSuites( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Filters the check suites by this type. + filterBy: CheckSuiteFilter + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CheckSuiteConnection + + # Comments made on the commit. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CommitCommentConnection! + + # The HTTP path for this Git object + commitResourcePath: URI! + + # The HTTP URL for this Git object + commitUrl: URI! + + # The datetime when this commit was committed. + committedDate: DateTime! + + # Check if commited via GitHub web UI. + committedViaWeb: Boolean! + + # Committership details of the commit. + committer: GitActor + + # The number of deletions in this commit. + deletions: Int! + + # The linear commit history starting from (and including) this commit, in the same order as `git log`. + history( + # Returns the elements in the list that come after the specified cursor. + after: String + + # If non-null, filters history to only show commits with matching authorship. + author: CommitAuthor + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # If non-null, filters history to only show commits touching files under this path. + path: String + + # Allows specifying a beginning time or date for fetching commits. + since: GitTimestamp + + # Allows specifying an ending time or date for fetching commits. + until: GitTimestamp + ): CommitHistoryConnection! + id: ID! + + # The Git commit message + message: String! + + # The Git commit message body + messageBody: String! + + # The commit message body rendered to HTML. + messageBodyHTML: HTML! + + # The Git commit message headline + messageHeadline: String! + + # The commit message headline rendered to HTML. + messageHeadlineHTML: HTML! + + # The Git object ID + oid: GitObjectID! + + # The parents of a commit. + parents( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CommitConnection! + + # The datetime when this commit was pushed. + pushedDate: DateTime + + # The Repository this commit belongs to + repository: Repository! + + # The HTTP path for this commit + resourcePath: URI! + + # Commit signing information, if present. + signature: GitSignature + + # Status information for this commit + status: Status + + # Returns a URL to download a tarball archive for a repository. + # Note: For private repositories, these links are temporary and expire after five minutes. + tarballUrl: URI! + + # Commit's root Tree + tree: Tree! + + # The HTTP path for the tree of this commit + treeResourcePath: URI! + + # The HTTP URL for the tree of this commit + treeUrl: URI! + + # The HTTP URL for this commit + url: URI! + + # Check if the viewer is able to change their subscription status for the repository. + viewerCanSubscribe: Boolean! + + # Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. + viewerSubscription: SubscriptionState + + # Returns a URL to download a zipball archive for a repository. + # Note: For private repositories, these links are temporary and expire after five minutes. + zipballUrl: URI! +} + +# Specifies an author for filtering Git commits. +input CommitAuthor { + # Email addresses to filter by. Commits authored by any of the specified email addresses will be returned. + emails: [String!] + + # ID of a User to filter by. If non-null, only commits authored by this user + # will be returned. This field takes precedence over emails. + id: ID +} + +# Represents a comment on a given Commit. +type CommitComment implements Comment & Deletable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # Identifies the comment body. + body: String! + + # Identifies the comment body rendered to HTML. + bodyHTML: HTML! + + # The body rendered to text. + bodyText: String! + + # Identifies the commit associated with the comment, if the commit exists. + commit: Commit + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The actor who edited the comment. + editor: Actor + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # Identifies the file path associated with the comment. + path: String + + # Identifies the line position associated with the comment. + position: Int + + # Identifies when the comment was published at. + publishedAt: DateTime + + # A list of reactions grouped by content left on the subject. + reactionGroups: [ReactionGroup!] + + # A list of Reactions left on the Issue. + reactions( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Allows filtering Reactions by emoji. + content: ReactionContent + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows specifying the order in which reactions are returned. + orderBy: ReactionOrder + ): ReactionConnection! + + # The repository associated with this node. + repository: Repository! + + # The HTTP path permalink for this commit comment. + resourcePath: URI! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL permalink for this commit comment. + url: URI! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Check if the current viewer can delete this object. + viewerCanDelete: Boolean! + + # Can user react to this subject + viewerCanReact: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! +} + +# The connection type for CommitComment. +type CommitCommentConnection { + # A list of edges. + edges: [CommitCommentEdge] + + # A list of nodes. + nodes: [CommitComment] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type CommitCommentEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: CommitComment +} + +# A thread of comments on a commit. +type CommitCommentThread implements Node & RepositoryNode { + # The comments that exist in this thread. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CommitCommentConnection! + + # The commit the comments were made on. + commit: Commit! + id: ID! + + # The file the comments were made on. + path: String + + # The position in the diff for the commit that the comment was made on. + position: Int + + # The repository associated with this node. + repository: Repository! +} + +# The connection type for Commit. +type CommitConnection { + # A list of edges. + edges: [CommitEdge] + + # A list of nodes. + nodes: [Commit] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type CommitEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Commit +} + +# The connection type for Commit. +type CommitHistoryConnection { + edges: [CommitEdge] + + # A list of nodes. + nodes: [Commit] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a 'converted_note_to_issue' event on a given issue or pull request. +type ConvertedNoteToIssueEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# Autogenerated input type of CreateCheckRun +input CreateCheckRunInput { + # Possible further actions the integrator can perform, which a user may trigger. + actions: [CheckRunAction!] + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The time that the check run finished. + completedAt: DateTime + + # The final conclusion of the check. + conclusion: CheckConclusionState + + # The URL of the integrator's site that has the full details of the check. + detailsUrl: URI + + # A reference for the run on the integrator's system. + externalId: String + + # The SHA of the head commit. + headSha: GitObjectID! + + # The name of the check. + name: String! + + # Descriptive details about the run. + output: CheckRunOutput + + # The node ID of the repository. + repositoryId: ID! + + # The time that the check run began. + startedAt: DateTime + + # The current status. + status: RequestableCheckStatusState +} + +# Autogenerated return type of CreateCheckRun +type CreateCheckRunPayload { + # The newly created check run. + checkRun: CheckRun + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of CreateCheckSuite +input CreateCheckSuiteInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The SHA of the head commit. + headSha: GitObjectID! + + # The Node ID of the repository. + repositoryId: ID! +} + +# Autogenerated return type of CreateCheckSuite +type CreateCheckSuitePayload { + # The newly created check suite. + checkSuite: CheckSuite + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of CreateIssue +input CreateIssueInput { + # The Node ID for the user assignee for this issue. + assigneeIds: [ID!] + + # The body for the issue description. + body: String + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # An array of Node IDs of labels for this issue. + labelIds: [ID!] + + # The Node ID of the milestone for this issue. + milestoneId: ID + + # An array of Node IDs for projects associated with this issue. + projectIds: [ID!] + + # The Node ID of the repository. + repositoryId: ID! + + # The title for the issue. + title: String! +} + +# Autogenerated return type of CreateIssue +type CreateIssuePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The new issue. + issue: Issue +} + +# Autogenerated input type of CreateProject +input CreateProjectInput { + # The description of project. + body: String + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of project. + name: String! + + # The owner ID to create the project under. + ownerId: ID! +} + +# Autogenerated return type of CreateProject +type CreateProjectPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The new project. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `project` will change from `Project!` to `Project`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + project: Project! +} + +# Represents a mention made by one issue or pull request to another. +type CrossReferencedEvent implements Node & UniformResourceLocatable { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Reference originated in a different repository. + isCrossRepository: Boolean! + + # Identifies when the reference was made. + referencedAt: DateTime! + + # The HTTP path for this pull request. + resourcePath: URI! + + # Issue or pull request that made the reference. + source: ReferencedSubject! + + # Issue or pull request to which the reference was made. + target: ReferencedSubject! + + # The HTTP URL for this pull request. + url: URI! + + # Checks if the target will be closed when the source is merged. + willCloseTarget: Boolean! +} + +# An ISO-8601 encoded date string. +scalar Date + +# An ISO-8601 encoded UTC date string. +scalar DateTime + +# Autogenerated input type of DeclineTopicSuggestion +input DeclineTopicSuggestionInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of the suggested topic. + name: String! + + # The reason why the suggested topic is declined. + reason: TopicSuggestionDeclineReason! + + # The Node ID of the repository. + repositoryId: ID! +} + +# Autogenerated return type of DeclineTopicSuggestion +type DeclineTopicSuggestionPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The declined topic. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `topic` will change from `Topic!` to `Topic`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + topic: Topic! +} + +# The possible default permissions for repositories. +enum DefaultRepositoryPermissionField { + # Can read, write, and administrate repos by default + ADMIN + + # No access + NONE + + # Can read repos by default + READ + + # Can read and write repos by default + WRITE +} + +# Entities that can be deleted. +interface Deletable { + # Check if the current viewer can delete this object. + viewerCanDelete: Boolean! +} + +# Autogenerated input type of DeleteIssueComment +input DeleteIssueCommentInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ID of the comment to delete. + id: ID! +} + +# Autogenerated return type of DeleteIssueComment +type DeleteIssueCommentPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of DeleteProjectCard +input DeleteProjectCardInput { + # The id of the card to delete. + cardId: ID! + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated return type of DeleteProjectCard +type DeleteProjectCardPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The column the deleted card was in. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `column` will change from `ProjectColumn!` to `ProjectColumn`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + column: ProjectColumn! + + # The deleted card ID. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `deletedCardId` will change from `ID!` to `ID`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + deletedCardId: ID! +} + +# Autogenerated input type of DeleteProjectColumn +input DeleteProjectColumnInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The id of the column to delete. + columnId: ID! +} + +# Autogenerated return type of DeleteProjectColumn +type DeleteProjectColumnPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The deleted column ID. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `deletedColumnId` will change from `ID!` to `ID`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + deletedColumnId: ID! + + # The project the deleted column was in. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `project` will change from `Project!` to `Project`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + project: Project! +} + +# Autogenerated input type of DeleteProject +input DeleteProjectInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Project ID to update. + projectId: ID! +} + +# Autogenerated return type of DeleteProject +type DeleteProjectPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The repository or organization the project was removed from. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `owner` will change from `ProjectOwner!` to `ProjectOwner`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + owner: ProjectOwner! +} + +# Autogenerated input type of DeletePullRequestReview +input DeletePullRequestReviewInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the pull request review to delete. + pullRequestReviewId: ID! +} + +# Autogenerated return type of DeletePullRequestReview +type DeletePullRequestReviewPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The deleted pull request review. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequestReview` will change from `PullRequestReview!` to `PullRequestReview`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequestReview: PullRequestReview! +} + +# Represents a 'demilestoned' event on a given issue or pull request. +type DemilestonedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the milestone title associated with the 'demilestoned' event. + milestoneTitle: String! + + # Object referenced by event. + subject: MilestoneItem! +} + +# A repository deploy key. +type DeployKey implements Node { + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # The deploy key. + key: String! + + # Whether or not the deploy key is read only. + readOnly: Boolean! + + # The deploy key title. + title: String! + + # Whether or not the deploy key has been verified. + verified: Boolean! +} + +# The connection type for DeployKey. +type DeployKeyConnection { + # A list of edges. + edges: [DeployKeyEdge] + + # A list of nodes. + nodes: [DeployKey] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type DeployKeyEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: DeployKey +} + +# Represents a 'deployed' event on a given pull request. +type DeployedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + + # The deployment associated with the 'deployed' event. + deployment: Deployment! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # The ref associated with the 'deployed' event. + ref: Ref +} + +# Represents triggered deployment instance. +type Deployment implements Node { + # Identifies the commit sha of the deployment. + commit: Commit + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the actor who triggered the deployment. + creator: Actor + + # Identifies the primary key from the database. + databaseId: Int + + # The deployment description. + description: String + + # The environment to which this deployment was made. + environment: String + id: ID! + + # The latest status of this deployment. + latestStatus: DeploymentStatus + + # Extra information that a deployment system might need. + payload: String + + # Identifies the repository associated with the deployment. + repository: Repository! + + # The current state of the deployment. + state: DeploymentState + + # A list of statuses associated with the deployment. + statuses( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): DeploymentStatusConnection + + # The deployment task. + task: String + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! +} + +# The connection type for Deployment. +type DeploymentConnection { + # A list of edges. + edges: [DeploymentEdge] + + # A list of nodes. + nodes: [Deployment] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type DeploymentEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Deployment +} + +# Represents a 'deployment_environment_changed' event on a given pull request. +type DeploymentEnvironmentChangedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The deployment status that updated the deployment environment. + deploymentStatus: DeploymentStatus! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! +} + +# The possible states in which a deployment can be. +enum DeploymentState { + # The pending deployment was not updated after 30 minutes. + ABANDONED + + # The deployment is currently active. + ACTIVE + + # An inactive transient deployment. + DESTROYED + + # The deployment experienced an error. + ERROR + + # The deployment has failed. + FAILURE + + # The deployment is inactive. + INACTIVE + + # The deployment is pending. + PENDING +} + +# Describes the status of a given deployment attempt. +type DeploymentStatus implements Node { + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the actor who triggered the deployment. + creator: Actor + + # Identifies the deployment associated with status. + deployment: Deployment! + + # Identifies the description of the deployment. + description: String + + # Identifies the environment URL of the deployment. + environmentUrl: URI + id: ID! + + # Identifies the log URL of the deployment. + logUrl: URI + + # Identifies the current state of the deployment. + state: DeploymentStatusState! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! +} + +# The connection type for DeploymentStatus. +type DeploymentStatusConnection { + # A list of edges. + edges: [DeploymentStatusEdge] + + # A list of nodes. + nodes: [DeploymentStatus] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type DeploymentStatusEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: DeploymentStatus +} + +# The possible states for a deployment status. +enum DeploymentStatusState { + # The deployment experienced an error. + ERROR + + # The deployment has failed. + FAILURE + + # The deployment is inactive. + INACTIVE + + # The deployment is pending. + PENDING + + # The deployment was successful. + SUCCESS +} + +# Autogenerated input type of DismissPullRequestReview +input DismissPullRequestReviewInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The contents of the pull request review dismissal message. + message: String! + + # The Node ID of the pull request review to modify. + pullRequestReviewId: ID! +} + +# Autogenerated return type of DismissPullRequestReview +type DismissPullRequestReviewPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The dismissed pull request review. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequestReview` will change from `PullRequestReview!` to `PullRequestReview`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequestReview: PullRequestReview! +} + +# Specifies a review comment to be left with a Pull Request Review. +input DraftPullRequestReviewComment { + # Body of the comment to leave. + body: String! + + # Path to the file being commented on. + path: String! + + # Position in the file to leave a comment on. + position: Int! +} + +# An external identity provisioned by SAML SSO or SCIM. +type ExternalIdentity implements Node { + # The GUID for this identity + guid: String! + id: ID! + + # Organization invitation for this SCIM-provisioned external identity + organizationInvitation: OrganizationInvitation + + # SAML Identity attributes + samlIdentity: ExternalIdentitySamlAttributes + + # SCIM Identity attributes + scimIdentity: ExternalIdentityScimAttributes + + # User linked to this external identity. Will be NULL if this identity has not been claimed by an organization member. + user: User +} + +# The connection type for ExternalIdentity. +type ExternalIdentityConnection { + # A list of edges. + edges: [ExternalIdentityEdge] + + # A list of nodes. + nodes: [ExternalIdentity] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ExternalIdentityEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ExternalIdentity +} + +# SAML attributes for the External Identity +type ExternalIdentitySamlAttributes { + # The NameID of the SAML identity + nameId: String +} + +# SCIM attributes for the External Identity +type ExternalIdentityScimAttributes { + # The userName of the SCIM identity + username: String +} + +# The connection type for User. +type FollowerConnection { + # A list of edges. + edges: [UserEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# The connection type for User. +type FollowingConnection { + # A list of edges. + edges: [UserEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# A Gist. +type Gist implements Node & Starrable { + # A list of comments associated with the gist + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): GistCommentConnection! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The gist description. + description: String + id: ID! + + # Whether the gist is public or not. + isPublic: Boolean! + + # The gist name. + name: String! + + # The gist owner. + owner: RepositoryOwner + + # Identifies when the gist was last pushed to. + pushedAt: DateTime + + # A list of users who have starred this starrable. + stargazers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: StarOrder + ): StargazerConnection! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # Returns a boolean indicating whether the viewing user has starred this starrable. + viewerHasStarred: Boolean! +} + +# Represents a comment on an Gist. +type GistComment implements Comment & Deletable & Node & Updatable & UpdatableComment { + # The actor who authored the comment. + author: Actor + + # Author's association with the gist. + authorAssociation: CommentAuthorAssociation! + + # Identifies the comment body. + body: String! + + # The comment body rendered to HTML. + bodyHTML: HTML! + + # The body rendered to text. + bodyText: String! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The actor who edited the comment. + editor: Actor + + # The associated gist. + gist: Gist! + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # Identifies when the comment was published at. + publishedAt: DateTime + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Check if the current viewer can delete this object. + viewerCanDelete: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! +} + +# The connection type for GistComment. +type GistCommentConnection { + # A list of edges. + edges: [GistCommentEdge] + + # A list of nodes. + nodes: [GistComment] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type GistCommentEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: GistComment +} + +# The connection type for Gist. +type GistConnection { + # A list of edges. + edges: [GistEdge] + + # A list of nodes. + nodes: [Gist] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type GistEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Gist +} + +# Ordering options for gist connections +input GistOrder { + # The ordering direction. + direction: OrderDirection! + + # The field to order repositories by. + field: GistOrderField! +} + +# Properties by which gist connections can be ordered. +enum GistOrderField { + # Order gists by creation time + CREATED_AT + + # Order gists by push time + PUSHED_AT + + # Order gists by update time + UPDATED_AT +} + +# The privacy of a Gist +enum GistPrivacy { + # Gists that are public and secret + ALL + + # Public + PUBLIC + + # Secret + SECRET +} + +# Represents an actor in a Git commit (ie. an author or committer). +type GitActor { + # A URL pointing to the author's public avatar. + avatarUrl( + # The size of the resulting square image. + size: Int + ): URI! + + # The timestamp of the Git action (authoring or committing). + date: GitTimestamp + + # The email in the Git commit. + email: String + + # The name in the Git commit. + name: String + + # The GitHub user corresponding to the email field. Null if no such user exists. + user: User +} + +# Represents information about the GitHub instance. +type GitHubMetadata { + # Returns a String that's a SHA of `github-services` + gitHubServicesSha: GitObjectID! + + # IP addresses that users connect to for git operations + gitIpAddresses: [String!] + + # IP addresses that service hooks are sent from + hookIpAddresses: [String!] + + # IP addresses that the importer connects from + importerIpAddresses: [String!] + + # Whether or not users are verified + isPasswordAuthenticationVerifiable: Boolean! + + # IP addresses for GitHub Pages' A records + pagesIpAddresses: [String!] +} + +# Represents a Git object. +interface GitObject { + # An abbreviated version of the Git object ID + abbreviatedOid: String! + + # The HTTP path for this Git object + commitResourcePath: URI! + + # The HTTP URL for this Git object + commitUrl: URI! + id: ID! + + # The Git object ID + oid: GitObjectID! + + # The Repository the Git object belongs to + repository: Repository! +} + +# A Git object ID. +scalar GitObjectID + +# Git SSH string +scalar GitSSHRemote + +# Information about a signature (GPG or S/MIME) on a Commit or Tag. +interface GitSignature { + # Email used to sign this object. + email: String! + + # True if the signature is valid and verified by GitHub. + isValid: Boolean! + + # Payload for GPG signing object. Raw ODB object without the signature header. + payload: String! + + # ASCII-armored signature header from object. + signature: String! + + # GitHub user corresponding to the email signing this commit. + signer: User + + # The state of this signature. `VALID` if signature is valid and verified by + # GitHub, otherwise represents reason why signature is considered invalid. + state: GitSignatureState! + + # True if the signature was made with GitHub's signing key. + wasSignedByGitHub: Boolean! +} + +# The state of a Git signature. +enum GitSignatureState { + # The signing certificate or its chain could not be verified + BAD_CERT + + # Invalid email used for signing + BAD_EMAIL + + # Signing key expired + EXPIRED_KEY + + # Internal error - the GPG verification service misbehaved + GPGVERIFY_ERROR + + # Internal error - the GPG verification service is unavailable at the moment + GPGVERIFY_UNAVAILABLE + + # Invalid signature + INVALID + + # Malformed signature + MALFORMED_SIG + + # The usage flags for the key that signed this don't allow signing + NOT_SIGNING_KEY + + # Email used for signing not known to GitHub + NO_USER + + # Valid siganture, though certificate revocation check failed + OCSP_ERROR + + # Valid signature, pending certificate revocation checking + OCSP_PENDING + + # One or more certificates in chain has been revoked + OCSP_REVOKED + + # Key used for signing not known to GitHub + UNKNOWN_KEY + + # Unknown signature type + UNKNOWN_SIG_TYPE + + # Unsigned + UNSIGNED + + # Email used for signing unverified on GitHub + UNVERIFIED_EMAIL + + # Valid signature and verified by GitHub + VALID +} + +# An ISO-8601 encoded date string. Unlike the DateTime type, GitTimestamp is not converted in UTC. +scalar GitTimestamp + +# Represents a GPG signature on a Commit or Tag. +type GpgSignature implements GitSignature { + # Email used to sign this object. + email: String! + + # True if the signature is valid and verified by GitHub. + isValid: Boolean! + + # Hex-encoded ID of the key that signed this object. + keyId: String + + # Payload for GPG signing object. Raw ODB object without the signature header. + payload: String! + + # ASCII-armored signature header from object. + signature: String! + + # GitHub user corresponding to the email signing this commit. + signer: User + + # The state of this signature. `VALID` if signature is valid and verified by + # GitHub, otherwise represents reason why signature is considered invalid. + state: GitSignatureState! + + # True if the signature was made with GitHub's signing key. + wasSignedByGitHub: Boolean! +} + +# A string containing HTML code. +scalar HTML + +# Represents a 'head_ref_deleted' event on a given pull request. +type HeadRefDeletedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the Ref associated with the `head_ref_deleted` event. + headRef: Ref + + # Identifies the name of the Ref associated with the `head_ref_deleted` event. + headRefName: String! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! +} + +# Represents a 'head_ref_force_pushed' event on a given pull request. +type HeadRefForcePushedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the after commit SHA for the 'head_ref_force_pushed' event. + afterCommit: Commit + + # Identifies the before commit SHA for the 'head_ref_force_pushed' event. + beforeCommit: Commit + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # Identifies the fully qualified ref name for the 'head_ref_force_pushed' event. + ref: Ref +} + +# Represents a 'head_ref_restored' event on a given pull request. +type HeadRefRestoredEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! +} + +# An Issue is a place to discuss ideas, enhancements, tasks, and bugs for a project. +type Issue implements Assignable & Closable & Comment & Labelable & Lockable & Node & Reactable & RepositoryNode & Subscribable & UniformResourceLocatable & Updatable & UpdatableComment { + # Reason that the conversation was locked. + activeLockReason: LockReason + + # A list of Users assigned to this object. + assignees( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # Identifies the body of the issue. + body: String! + + # Identifies the body of the issue rendered to HTML. + bodyHTML: HTML! + + # Identifies the body of the issue rendered to text. + bodyText: String! + + # `true` if the object is closed (definition of closed may depend on type) + closed: Boolean! + + # Identifies the date and time when the object was closed. + closedAt: DateTime + + # A list of comments associated with the Issue. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): IssueCommentConnection! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The actor who edited the comment. + editor: Actor + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # A list of labels associated with the object. + labels( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): LabelConnection + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # `true` if the object is locked + locked: Boolean! + + # Identifies the milestone associated with the issue. + milestone: Milestone + + # Identifies the issue number. + number: Int! + + # A list of Users that are participating in the Issue conversation. + participants( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # List of project cards associated with this issue. + projectCards( + # Returns the elements in the list that come after the specified cursor. + after: String + + # A list of archived states to filter the cards by + archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ProjectCardConnection! + + # Identifies when the comment was published at. + publishedAt: DateTime + + # A list of reactions grouped by content left on the subject. + reactionGroups: [ReactionGroup!] + + # A list of Reactions left on the Issue. + reactions( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Allows filtering Reactions by emoji. + content: ReactionContent + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows specifying the order in which reactions are returned. + orderBy: ReactionOrder + ): ReactionConnection! + + # The repository associated with this node. + repository: Repository! + + # The HTTP path for this issue + resourcePath: URI! + + # Identifies the state of the issue. + state: IssueState! + + # A list of events, comments, commits, etc. associated with the issue. + timeline( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows filtering timeline events by a `since` timestamp. + since: DateTime + ): IssueTimelineConnection! + + # A list of events, comments, commits, etc. associated with the issue. + timelineItems( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Filter timeline items by type. + itemTypes: [IssueTimelineItemsItemType!] + + # Returns the last _n_ elements from the list. + last: Int + + # Filter timeline items by a `since` timestamp. + since: DateTime + + # Skips the first _n_ elements in the list. + skip: Int + ): IssueTimelineItemsConnection! + + # Identifies the issue title. + title: String! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this issue + url: URI! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Can user react to this subject + viewerCanReact: Boolean! + + # Check if the viewer is able to change their subscription status for the repository. + viewerCanSubscribe: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! + + # Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. + viewerSubscription: SubscriptionState +} + +# Represents a comment on an Issue. +type IssueComment implements Comment & Deletable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # The body as Markdown. + body: String! + + # The body rendered to HTML. + bodyHTML: HTML! + + # The body rendered to text. + bodyText: String! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The actor who edited the comment. + editor: Actor + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # Identifies the issue associated with the comment. + issue: Issue! + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # Identifies when the comment was published at. + publishedAt: DateTime + + # Returns the pull request associated with the comment, if this comment was made on a + # pull request. + pullRequest: PullRequest + + # A list of reactions grouped by content left on the subject. + reactionGroups: [ReactionGroup!] + + # A list of Reactions left on the Issue. + reactions( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Allows filtering Reactions by emoji. + content: ReactionContent + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows specifying the order in which reactions are returned. + orderBy: ReactionOrder + ): ReactionConnection! + + # The repository associated with this node. + repository: Repository! + + # The HTTP path for this issue comment + resourcePath: URI! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this issue comment + url: URI! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Check if the current viewer can delete this object. + viewerCanDelete: Boolean! + + # Can user react to this subject + viewerCanReact: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! +} + +# The connection type for IssueComment. +type IssueCommentConnection { + # A list of edges. + edges: [IssueCommentEdge] + + # A list of nodes. + nodes: [IssueComment] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type IssueCommentEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: IssueComment +} + +# The connection type for Issue. +type IssueConnection { + # A list of edges. + edges: [IssueEdge] + + # A list of nodes. + nodes: [Issue] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type IssueEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Issue +} + +# Ways in which to filter lists of issues. +input IssueFilters { + # List issues assigned to given name. Pass in `null` for issues with no assigned + # user, and `*` for issues assigned to any user. + assignee: String + + # List issues created by given name. + createdBy: String + + # List issues where the list of label names exist on the issue. + labels: [String!] + + # List issues where the given name is mentioned in the issue. + mentioned: String + + # List issues by given milestone argument. If an string representation of an + # integer is passed, it should refer to a milestone by its number field. Pass in + # `null` for issues with no milestone, and `*` for issues that are assigned to any milestone. + milestone: String + + # List issues that have been updated at or after the given date. + since: DateTime + + # List issues filtered by the list of states given. + states: [IssueState!] + + # List issues subscribed to by viewer. + viewerSubscribed: Boolean = false +} + +# Used for return value of Repository.issueOrPullRequest. +union IssueOrPullRequest = Issue | PullRequest + +# Ways in which lists of issues can be ordered upon return. +input IssueOrder { + # The direction in which to order issues by the specified field. + direction: OrderDirection! + + # The field in which to order issues by. + field: IssueOrderField! +} + +# Properties by which issue connections can be ordered. +enum IssueOrderField { + # Order issues by comment count + COMMENTS + + # Order issues by creation time + CREATED_AT + + # Order issues by update time + UPDATED_AT +} + +# The possible PubSub channels for an issue. +enum IssuePubSubTopic { + # The channel ID for marking an issue as read. + MARKASREAD + + # The channel ID for updating items on the issue timeline. + TIMELINE + + # The channel ID for observing issue updates. + UPDATED +} + +# The possible states of an issue. +enum IssueState { + # An issue that has been closed + CLOSED + + # An issue that is still open + OPEN +} + +# The connection type for IssueTimelineItem. +type IssueTimelineConnection { + # A list of edges. + edges: [IssueTimelineItemEdge] + + # A list of nodes. + nodes: [IssueTimelineItem] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An item in an issue timeline +union IssueTimelineItem = AssignedEvent | ClosedEvent | Commit | CrossReferencedEvent | DemilestonedEvent | IssueComment | LabeledEvent | LockedEvent | MilestonedEvent | ReferencedEvent | RenamedTitleEvent | ReopenedEvent | SubscribedEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnsubscribedEvent + +# An edge in a connection. +type IssueTimelineItemEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: IssueTimelineItem +} + +# An item in an issue timeline +union IssueTimelineItems = AddedToProjectEvent | AssignedEvent | ClosedEvent | CommentDeletedEvent | ConvertedNoteToIssueEvent | CrossReferencedEvent | DemilestonedEvent | IssueComment | LabeledEvent | LockedEvent | MentionedEvent | MilestonedEvent | MovedColumnsInProjectEvent | ReferencedEvent | RemovedFromProjectEvent | RenamedTitleEvent | ReopenedEvent | SubscribedEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnsubscribedEvent + +# The connection type for IssueTimelineItems. +type IssueTimelineItemsConnection { + # A list of edges. + edges: [IssueTimelineItemsEdge] + + # Identifies the count of items after applying `before` and `after` filters. + filteredCount: Int! + + # A list of nodes. + nodes: [IssueTimelineItems] + + # Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing. + pageCount: Int! + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! + + # Identifies the date and time when the timeline was last updated. + updatedAt: DateTime! +} + +# An edge in a connection. +type IssueTimelineItemsEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: IssueTimelineItems +} + +# The possible item types found in a timeline. +enum IssueTimelineItemsItemType { + # Represents a 'added_to_project' event on a given issue or pull request. + ADDED_TO_PROJECT_EVENT + + # Represents an 'assigned' event on any assignable object. + ASSIGNED_EVENT + + # Represents a 'closed' event on any `Closable`. + CLOSED_EVENT + + # Represents a 'comment_deleted' event on a given issue or pull request. + COMMENT_DELETED_EVENT + + # Represents a 'converted_note_to_issue' event on a given issue or pull request. + CONVERTED_NOTE_TO_ISSUE_EVENT + + # Represents a mention made by one issue or pull request to another. + CROSS_REFERENCED_EVENT + + # Represents a 'demilestoned' event on a given issue or pull request. + DEMILESTONED_EVENT + + # Represents a comment on an Issue. + ISSUE_COMMENT + + # Represents a 'labeled' event on a given issue or pull request. + LABELED_EVENT + + # Represents a 'locked' event on a given issue or pull request. + LOCKED_EVENT + + # Represents a 'marked_as_duplicate' event on a given issue or pull request. + MARKED_AS_DUPLICATE_EVENT + + # Represents a 'mentioned' event on a given issue or pull request. + MENTIONED_EVENT + + # Represents a 'milestoned' event on a given issue or pull request. + MILESTONED_EVENT + + # Represents a 'moved_columns_in_project' event on a given issue or pull request. + MOVED_COLUMNS_IN_PROJECT_EVENT + + # Represents a 'referenced' event on a given `ReferencedSubject`. + REFERENCED_EVENT + + # Represents a 'removed_from_project' event on a given issue or pull request. + REMOVED_FROM_PROJECT_EVENT + + # Represents a 'renamed' event on a given issue or pull request + RENAMED_TITLE_EVENT + + # Represents a 'reopened' event on any `Closable`. + REOPENED_EVENT + + # Represents a 'subscribed' event on a given `Subscribable`. + SUBSCRIBED_EVENT + + # Represents an 'unassigned' event on any assignable object. + UNASSIGNED_EVENT + + # Represents an 'unlabeled' event on a given issue or pull request. + UNLABELED_EVENT + + # Represents an 'unlocked' event on a given issue or pull request. + UNLOCKED_EVENT + + # Represents an 'unmarked_as_duplicate' event on a given issue or pull request. + UNMARKED_AS_DUPLICATE_EVENT + + # Represents an 'unsubscribed' event on a given `Subscribable`. + UNSUBSCRIBED_EVENT +} + +# A label for categorizing Issues or Milestones with a given Repository. +type Label implements Node { + # Identifies the label color. + color: String! + + # Identifies the date and time when the label was created. + createdAt: DateTime + + # A brief description of this label. + description: String + id: ID! + + # Indicates whether or not this is a default label. + isDefault: Boolean! + + # A list of issues associated with this label. + issues( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Filtering options for issues returned from the connection. + filterBy: IssueFilters + + # Returns the first _n_ elements from the list. + first: Int + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for issues returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the issues by. + states: [IssueState!] + ): IssueConnection! + + # Identifies the label name. + name: String! + + # A list of pull requests associated with this label. + pullRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # The base ref name to filter the pull requests by. + baseRefName: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # The head ref name to filter the pull requests by. + headRefName: String + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for pull requests returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the pull requests by. + states: [PullRequestState!] + ): PullRequestConnection! + + # The repository associated with this label. + repository: Repository! + + # The HTTP path for this label. + resourcePath: URI! + + # Identifies the date and time when the label was last updated. + updatedAt: DateTime + + # The HTTP URL for this label. + url: URI! +} + +# The connection type for Label. +type LabelConnection { + # A list of edges. + edges: [LabelEdge] + + # A list of nodes. + nodes: [Label] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type LabelEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Label +} + +# An object that can have labels assigned to it. +interface Labelable { + # A list of labels associated with the object. + labels( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): LabelConnection +} + +# Represents a 'labeled' event on a given issue or pull request. +type LabeledEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the label associated with the 'labeled' event. + label: Label! + + # Identifies the `Labelable` associated with the event. + labelable: Labelable! +} + +# Represents a given language found in repositories. +type Language implements Node { + # The color defined for the current language. + color: String + id: ID! + + # The name of the current language. + name: String! +} + +# A list of languages associated with the parent. +type LanguageConnection { + # A list of edges. + edges: [LanguageEdge] + + # A list of nodes. + nodes: [Language] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! + + # The total size in bytes of files written in that language. + totalSize: Int! +} + +# Represents the language of a repository. +type LanguageEdge { + cursor: String! + node: Language! + + # The number of bytes of code written in the language. + size: Int! +} + +# Ordering options for language connections. +input LanguageOrder { + # The ordering direction. + direction: OrderDirection! + + # The field to order languages by. + field: LanguageOrderField! +} + +# Properties by which language connections can be ordered. +enum LanguageOrderField { + # Order languages by the size of all files containing the language + SIZE +} + +# A repository's open source license +type License implements Node { + # The full text of the license + body: String! + + # The conditions set by the license + conditions: [LicenseRule]! + + # A human-readable description of the license + description: String + + # Whether the license should be featured + featured: Boolean! + + # Whether the license should be displayed in license pickers + hidden: Boolean! + id: ID! + + # Instructions on how to implement the license + implementation: String + + # The lowercased SPDX ID of the license + key: String! + + # The limitations set by the license + limitations: [LicenseRule]! + + # The license full name specified by <https://spdx.org/licenses> + name: String! + + # Customary short name if applicable (e.g, GPLv3) + nickname: String + + # The permissions set by the license + permissions: [LicenseRule]! + + # Whether the license is a pseudo-license placeholder (e.g., other, no-license) + pseudoLicense: Boolean! + + # Short identifier specified by <https://spdx.org/licenses> + spdxId: String + + # URL to the license on <https://choosealicense.com> + url: URI +} + +# Describes a License's conditions, permissions, and limitations +type LicenseRule { + # A description of the rule + description: String! + + # The machine-readable rule key + key: String! + + # The human-readable rule label + label: String! +} + +# Autogenerated input type of LockLockable +input LockLockableInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # A reason for why the issue or pull request will be locked. + lockReason: LockReason + + # ID of the issue or pull request to be locked. + lockableId: ID! +} + +# Autogenerated return type of LockLockable +type LockLockablePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The item that was locked. + lockedRecord: Lockable +} + +# The possible reasons that an issue or pull request was locked. +enum LockReason { + # The issue or pull request was locked because the conversation was off-topic. + OFF_TOPIC + + # The issue or pull request was locked because the conversation was resolved. + RESOLVED + + # The issue or pull request was locked because the conversation was spam. + SPAM + + # The issue or pull request was locked because the conversation was too heated. + TOO_HEATED +} + +# An object that can be locked. +interface Lockable { + # Reason that the conversation was locked. + activeLockReason: LockReason + + # `true` if the object is locked + locked: Boolean! +} + +# Represents a 'locked' event on a given issue or pull request. +type LockedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Reason that the conversation was locked (optional). + lockReason: LockReason + + # Object that was locked. + lockable: Lockable! +} + +# A public description of a Marketplace category. +type MarketplaceCategory implements Node { + # The category's description. + description: String + + # The technical description of how apps listed in this category work with GitHub. + howItWorks: String + id: ID! + + # The category's name. + name: String! + + # How many Marketplace listings have this as their primary category. + primaryListingCount: Int! + + # The HTTP path for this Marketplace category. + resourcePath: URI! + + # How many Marketplace listings have this as their secondary category. + secondaryListingCount: Int! + + # The short name of the category used in its URL. + slug: String! + + # The HTTP URL for this Marketplace category. + url: URI! +} + +# A listing in the GitHub integration marketplace. +type MarketplaceListing implements Node { + # The GitHub App this listing represents. + app: App + + # URL to the listing owner's company site. + companyUrl: URI + + # The HTTP path for configuring access to the listing's integration or OAuth app + configurationResourcePath: URI! + + # The HTTP URL for configuring access to the listing's integration or OAuth app + configurationUrl: URI! + + # URL to the listing's documentation. + documentationUrl: URI + + # The listing's detailed description. + extendedDescription: String + + # The listing's detailed description rendered to HTML. + extendedDescriptionHTML: HTML! + + # The listing's introductory description. + fullDescription: String! + + # The listing's introductory description rendered to HTML. + fullDescriptionHTML: HTML! + + # Whether this listing has been submitted for review from GitHub for approval to be displayed in the Marketplace. + hasApprovalBeenRequested: Boolean! + + # Does this listing have any plans with a free trial? + hasPublishedFreeTrialPlans: Boolean! + + # Does this listing have a terms of service link? + hasTermsOfService: Boolean! + + # A technical description of how this app works with GitHub. + howItWorks: String + + # The listing's technical description rendered to HTML. + howItWorksHTML: HTML! + id: ID! + + # URL to install the product to the viewer's account or organization. + installationUrl: URI + + # Whether this listing's app has been installed for the current viewer + installedForViewer: Boolean! + + # Whether this listing has been approved for display in the Marketplace. + isApproved: Boolean! + + # Whether this listing has been removed from the Marketplace. + isDelisted: Boolean! + + # Whether this listing is still an editable draft that has not been submitted + # for review and is not publicly visible in the Marketplace. + isDraft: Boolean! + + # Whether the product this listing represents is available as part of a paid plan. + isPaid: Boolean! + + # Whether this listing has been rejected by GitHub for display in the Marketplace. + isRejected: Boolean! + + # The hex color code, without the leading '#', for the logo background. + logoBackgroundColor: String! + + # URL for the listing's logo image. + logoUrl( + # The size in pixels of the resulting square image. + size: Int = 400 + ): URI + + # The listing's full name. + name: String! + + # The listing's very short description without a trailing period or ampersands. + normalizedShortDescription: String! + + # URL to the listing's detailed pricing. + pricingUrl: URI + + # The category that best describes the listing. + primaryCategory: MarketplaceCategory! + + # URL to the listing's privacy policy. + privacyPolicyUrl: URI! + + # The HTTP path for the Marketplace listing. + resourcePath: URI! + + # The URLs for the listing's screenshots. + screenshotUrls: [String]! + + # An alternate category that describes the listing. + secondaryCategory: MarketplaceCategory + + # The listing's very short description. + shortDescription: String! + + # The short name of the listing used in its URL. + slug: String! + + # URL to the listing's status page. + statusUrl: URI + + # An email address for support for this listing's app. + supportEmail: String + + # Either a URL or an email address for support for this listing's app. + supportUrl: URI! + + # URL to the listing's terms of service. + termsOfServiceUrl: URI + + # The HTTP URL for the Marketplace listing. + url: URI! + + # Can the current viewer add plans for this Marketplace listing. + viewerCanAddPlans: Boolean! + + # Can the current viewer approve this Marketplace listing. + viewerCanApprove: Boolean! + + # Can the current viewer delist this Marketplace listing. + viewerCanDelist: Boolean! + + # Can the current viewer edit this Marketplace listing. + viewerCanEdit: Boolean! + + # Can the current viewer edit the primary and secondary category of this + # Marketplace listing. + viewerCanEditCategories: Boolean! + + # Can the current viewer edit the plans for this Marketplace listing. + viewerCanEditPlans: Boolean! + + # Can the current viewer return this Marketplace listing to draft state + # so it becomes editable again. + viewerCanRedraft: Boolean! + + # Can the current viewer reject this Marketplace listing by returning it to + # an editable draft state or rejecting it entirely. + viewerCanReject: Boolean! + + # Can the current viewer request this listing be reviewed for display in + # the Marketplace. + viewerCanRequestApproval: Boolean! + + # Indicates whether the current user has an active subscription to this Marketplace listing. + viewerHasPurchased: Boolean! + + # Indicates if the current user has purchased a subscription to this Marketplace listing + # for all of the organizations the user owns. + viewerHasPurchasedForAllOrganizations: Boolean! + + # Does the current viewer role allow them to administer this Marketplace listing. + viewerIsListingAdmin: Boolean! +} + +# Look up Marketplace Listings +type MarketplaceListingConnection { + # A list of edges. + edges: [MarketplaceListingEdge] + + # A list of nodes. + nodes: [MarketplaceListing] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type MarketplaceListingEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: MarketplaceListing +} + +# Represents a 'mentioned' event on a given issue or pull request. +type MentionedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# Whether or not a PullRequest can be merged. +enum MergeableState { + # The pull request cannot be merged due to merge conflicts. + CONFLICTING + + # The pull request can be merged. + MERGEABLE + + # The mergeability of the pull request is still being calculated. + UNKNOWN +} + +# Represents a 'merged' event on a given pull request. +type MergedEvent implements Node & UniformResourceLocatable { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the commit associated with the `merge` event. + commit: Commit + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the Ref associated with the `merge` event. + mergeRef: Ref + + # Identifies the name of the Ref associated with the `merge` event. + mergeRefName: String! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # The HTTP path for this merged event. + resourcePath: URI! + + # The HTTP URL for this merged event. + url: URI! +} + +# Represents a Milestone object on a given repository. +type Milestone implements Closable & Node & UniformResourceLocatable { + # `true` if the object is closed (definition of closed may depend on type) + closed: Boolean! + + # Identifies the date and time when the object was closed. + closedAt: DateTime + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the actor who created the milestone. + creator: Actor + + # Identifies the description of the milestone. + description: String + + # Identifies the due date of the milestone. + dueOn: DateTime + id: ID! + + # A list of issues associated with the milestone. + issues( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Filtering options for issues returned from the connection. + filterBy: IssueFilters + + # Returns the first _n_ elements from the list. + first: Int + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for issues returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the issues by. + states: [IssueState!] + ): IssueConnection! + + # Identifies the number of the milestone. + number: Int! + + # A list of pull requests associated with the milestone. + pullRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # The base ref name to filter the pull requests by. + baseRefName: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # The head ref name to filter the pull requests by. + headRefName: String + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for pull requests returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the pull requests by. + states: [PullRequestState!] + ): PullRequestConnection! + + # The repository associated with this milestone. + repository: Repository! + + # The HTTP path for this milestone + resourcePath: URI! + + # Identifies the state of the milestone. + state: MilestoneState! + + # Identifies the title of the milestone. + title: String! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this milestone + url: URI! +} + +# The connection type for Milestone. +type MilestoneConnection { + # A list of edges. + edges: [MilestoneEdge] + + # A list of nodes. + nodes: [Milestone] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type MilestoneEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Milestone +} + +# Types that can be inside a Milestone. +union MilestoneItem = Issue | PullRequest + +# Ordering options for milestone connections. +input MilestoneOrder { + # The ordering direction. + direction: OrderDirection! + + # The field to order milestones by. + field: MilestoneOrderField! +} + +# Properties by which milestone connections can be ordered. +enum MilestoneOrderField { + # Order milestones by when they were created. + CREATED_AT + + # Order milestones by when they are due. + DUE_DATE + + # Order milestones by their number. + NUMBER + + # Order milestones by when they were last updated. + UPDATED_AT +} + +# The possible states of a milestone. +enum MilestoneState { + # A milestone that has been closed. + CLOSED + + # A milestone that is still open. + OPEN +} + +# Represents a 'milestoned' event on a given issue or pull request. +type MilestonedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the milestone title associated with the 'milestoned' event. + milestoneTitle: String! + + # Object referenced by event. + subject: MilestoneItem! +} + +# Autogenerated input type of MoveProjectCard +input MoveProjectCardInput { + # Place the new card after the card with this id. Pass null to place it at the top. + afterCardId: ID + + # The id of the card to move. + cardId: ID! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The id of the column to move it into. + columnId: ID! +} + +# Autogenerated return type of MoveProjectCard +type MoveProjectCardPayload { + # The new edge of the moved card. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `cardEdge` will change from `ProjectCardEdge!` to `ProjectCardEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + cardEdge: ProjectCardEdge! + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of MoveProjectColumn +input MoveProjectColumnInput { + # Place the new column after the column with this id. Pass null to place it at the front. + afterColumnId: ID + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The id of the column to move. + columnId: ID! +} + +# Autogenerated return type of MoveProjectColumn +type MoveProjectColumnPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The new edge of the moved column. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `columnEdge` will change from `ProjectColumnEdge!` to `ProjectColumnEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + columnEdge: ProjectColumnEdge! +} + +# Represents a 'moved_columns_in_project' event on a given issue or pull request. +type MovedColumnsInProjectEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# The root query for implementing GraphQL mutations. +type Mutation { + # Applies a suggested topic to the repository. + acceptTopicSuggestion(input: AcceptTopicSuggestionInput!): AcceptTopicSuggestionPayload + + # Adds assignees to an assignable object. + addAssigneesToAssignable(input: AddAssigneesToAssignableInput!): AddAssigneesToAssignablePayload + + # Adds a comment to an Issue or Pull Request. + addComment(input: AddCommentInput!): AddCommentPayload + + # Adds labels to a labelable object. + addLabelsToLabelable(input: AddLabelsToLabelableInput!): AddLabelsToLabelablePayload + + # Adds a card to a ProjectColumn. Either `contentId` or `note` must be provided but **not** both. + addProjectCard(input: AddProjectCardInput!): AddProjectCardPayload + + # Adds a column to a Project. + addProjectColumn(input: AddProjectColumnInput!): AddProjectColumnPayload + + # Adds a review to a Pull Request. + addPullRequestReview(input: AddPullRequestReviewInput!): AddPullRequestReviewPayload + + # Adds a comment to a review. + addPullRequestReviewComment(input: AddPullRequestReviewCommentInput!): AddPullRequestReviewCommentPayload + + # Adds a reaction to a subject. + addReaction(input: AddReactionInput!): AddReactionPayload + + # Adds a star to a Starrable. + addStar(input: AddStarInput!): AddStarPayload + + # Clears all labels from a labelable object. + clearLabelsFromLabelable(input: ClearLabelsFromLabelableInput!): ClearLabelsFromLabelablePayload + + # Close an issue. + closeIssue(input: CloseIssueInput!): CloseIssuePayload + + # Create a check run. + createCheckRun(input: CreateCheckRunInput!): CreateCheckRunPayload + + # Create a check suite + createCheckSuite(input: CreateCheckSuiteInput!): CreateCheckSuitePayload + + # Creates a new issue. + createIssue(input: CreateIssueInput!): CreateIssuePayload + + # Creates a new project. + createProject(input: CreateProjectInput!): CreateProjectPayload + + # Rejects a suggested topic for the repository. + declineTopicSuggestion(input: DeclineTopicSuggestionInput!): DeclineTopicSuggestionPayload + + # Deletes a issue comment. + deleteIssueComment(input: DeleteIssueCommentInput!): DeleteIssueCommentPayload + + # Deletes a project. + deleteProject(input: DeleteProjectInput!): DeleteProjectPayload + + # Deletes a project card. + deleteProjectCard(input: DeleteProjectCardInput!): DeleteProjectCardPayload + + # Deletes a project column. + deleteProjectColumn(input: DeleteProjectColumnInput!): DeleteProjectColumnPayload + + # Deletes a pull request review. + deletePullRequestReview(input: DeletePullRequestReviewInput!): DeletePullRequestReviewPayload + + # Dismisses an approved or rejected pull request review. + dismissPullRequestReview(input: DismissPullRequestReviewInput!): DismissPullRequestReviewPayload + + # Lock a lockable object + lockLockable(input: LockLockableInput!): LockLockablePayload + + # Moves a project card to another place. + moveProjectCard(input: MoveProjectCardInput!): MoveProjectCardPayload + + # Moves a project column to another place. + moveProjectColumn(input: MoveProjectColumnInput!): MoveProjectColumnPayload + + # Removes assignees from an assignable object. + removeAssigneesFromAssignable(input: RemoveAssigneesFromAssignableInput!): RemoveAssigneesFromAssignablePayload + + # Removes labels from a Labelable object. + removeLabelsFromLabelable(input: RemoveLabelsFromLabelableInput!): RemoveLabelsFromLabelablePayload + + # Removes outside collaborator from all repositories in an organization. + removeOutsideCollaborator(input: RemoveOutsideCollaboratorInput!): RemoveOutsideCollaboratorPayload + + # Removes a reaction from a subject. + removeReaction(input: RemoveReactionInput!): RemoveReactionPayload + + # Removes a star from a Starrable. + removeStar(input: RemoveStarInput!): RemoveStarPayload + + # Reopen a issue. + reopenIssue(input: ReopenIssueInput!): ReopenIssuePayload + + # Set review requests on a pull request. + requestReviews(input: RequestReviewsInput!): RequestReviewsPayload + + # Rerequests an existing check suite. + rerequestCheckSuite(input: RerequestCheckSuiteInput!): RerequestCheckSuitePayload + + # Marks a review thread as resolved. + resolveReviewThread(input: ResolveReviewThreadInput!): ResolveReviewThreadPayload + + # Submits a pending pull request review. + submitPullRequestReview(input: SubmitPullRequestReviewInput!): SubmitPullRequestReviewPayload + + # Unlock a lockable object + unlockLockable(input: UnlockLockableInput!): UnlockLockablePayload + + # Unmark an issue as a duplicate of another issue. + unmarkIssueAsDuplicate(input: UnmarkIssueAsDuplicateInput!): UnmarkIssueAsDuplicatePayload + + # Marks a review thread as unresolved. + unresolveReviewThread(input: UnresolveReviewThreadInput!): UnresolveReviewThreadPayload + + # Update a check run + updateCheckRun(input: UpdateCheckRunInput!): UpdateCheckRunPayload + + # Modifies the settings of an existing check suite + updateCheckSuitePreferences(input: UpdateCheckSuitePreferencesInput!): UpdateCheckSuitePreferencesPayload + + # Updates an Issue. + updateIssue(input: UpdateIssueInput!): UpdateIssuePayload + + # Updates a comment on an Issue. + updateIssueComment(input: UpdateIssueCommentInput!): UpdateIssueCommentPayload + + # Updates an existing project. + updateProject(input: UpdateProjectInput!): UpdateProjectPayload + + # Updates an existing project card. + updateProjectCard(input: UpdateProjectCardInput!): UpdateProjectCardPayload + + # Updates an existing project column. + updateProjectColumn(input: UpdateProjectColumnInput!): UpdateProjectColumnPayload + + # Updates the body of a pull request review. + updatePullRequestReview(input: UpdatePullRequestReviewInput!): UpdatePullRequestReviewPayload + + # Updates a pull request review comment. + updatePullRequestReviewComment(input: UpdatePullRequestReviewCommentInput!): UpdatePullRequestReviewCommentPayload + + # Updates the state for subscribable subjects. + updateSubscription(input: UpdateSubscriptionInput!): UpdateSubscriptionPayload + + # Replaces the repository's topics with the given topics. + updateTopics(input: UpdateTopicsInput!): UpdateTopicsPayload +} + +# An object with an ID. +interface Node { + # ID of the object. + id: ID! +} + +# Possible directions in which to order a list of items when provided an `orderBy` argument. +enum OrderDirection { + # Specifies an ascending order for a given `orderBy` argument. + ASC + + # Specifies a descending order for a given `orderBy` argument. + DESC +} + +# An account on GitHub, with one or more owners, that has repositories, members and teams. +type Organization implements Actor & Node & ProjectOwner & RegistryPackageOwner & RegistryPackageSearch & RepositoryOwner & UniformResourceLocatable { + # A URL pointing to the organization's public avatar. + avatarUrl( + # The size of the resulting square image. + size: Int + ): URI! + + # Identifies the primary key from the database. + databaseId: Int + + # The organization's public profile description. + description: String + + # The organization's public email. + email: String + id: ID! + + # Whether the organization has verified its profile email and website. + isVerified: Boolean! + + # The organization's public profile location. + location: String + + # The organization's login name. + login: String! + + # A list of users who are members of this organization. + members( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # The organization's public profile name. + name: String + + # The HTTP path creating a new team + newTeamResourcePath: URI! + + # The HTTP URL creating a new team + newTeamUrl: URI! + + # The billing email for the organization. + organizationBillingEmail: String + + # A list of repositories this user has pinned to their profile + pinnedRepositories( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # Find project by number. + project( + # The project number to find. + number: Int! + ): Project + + # A list of projects under the owner. + projects( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for projects returned from the connection + orderBy: ProjectOrder + + # Query to search projects by, currently only searching by name. + search: String + + # A list of states to filter the projects by. + states: [ProjectState!] + ): ProjectConnection! + + # The HTTP path listing organization's projects + projectsResourcePath: URI! + + # The HTTP URL listing organization's projects + projectsUrl: URI! + + # A list of repositories that the user owns. + repositories( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they are forks of another repository + isFork: Boolean + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # Find Repository. + repository( + # Name of Repository to find. + name: String! + ): Repository + + # When true the organization requires all members, billing managers, and outside + # collaborators to enable two-factor authentication. + requiresTwoFactorAuthentication: Boolean + + # The HTTP path for this organization. + resourcePath: URI! + + # The Organization's SAML Identity Providers + samlIdentityProvider: OrganizationIdentityProvider + + # Find an organization's team by its slug. + team( + # The name or slug of the team to find. + slug: String! + ): Team + + # A list of teams in this organization. + teams( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # If true, filters teams that are mapped to an LDAP Group (Enterprise only) + ldapMapped: Boolean + + # Ordering options for teams returned from the connection + orderBy: TeamOrder + + # If non-null, filters teams according to privacy + privacy: TeamPrivacy + + # If non-null, filters teams with query on team name and team slug + query: String + + # If non-null, filters teams according to whether the viewer is an admin or member on team + role: TeamRole + + # If true, restrict to only root teams + rootTeamsOnly: Boolean = false + + # User logins to filter by + userLogins: [String!] + ): TeamConnection! + + # The HTTP path listing organization's teams + teamsResourcePath: URI! + + # The HTTP URL listing organization's teams + teamsUrl: URI! + + # The HTTP URL for this organization. + url: URI! + + # Organization is adminable by the viewer. + viewerCanAdminister: Boolean! + + # Can the current viewer create new projects on this owner. + viewerCanCreateProjects: Boolean! + + # Viewer can create repositories on this organization + viewerCanCreateRepositories: Boolean! + + # Viewer can create teams on this organization. + viewerCanCreateTeams: Boolean! + + # Viewer is an active member of this organization. + viewerIsAMember: Boolean! + + # The organization's public profile URL. + websiteUrl: URI +} + +# The connection type for Organization. +type OrganizationConnection { + # A list of edges. + edges: [OrganizationEdge] + + # A list of nodes. + nodes: [Organization] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type OrganizationEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Organization +} + +# An Identity Provider configured to provision SAML and SCIM identities for Organizations +type OrganizationIdentityProvider implements Node { + # The digest algorithm used to sign SAML requests for the Identity Provider. + digestMethod: URI + + # External Identities provisioned by this Identity Provider + externalIdentities( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ExternalIdentityConnection! + id: ID! + + # The x509 certificate used by the Identity Provder to sign assertions and responses. + idpCertificate: X509Certificate + + # The Issuer Entity ID for the SAML Identity Provider + issuer: String + + # Organization this Identity Provider belongs to + organization: Organization + + # The signature algorithm used to sign SAML requests for the Identity Provider. + signatureMethod: URI + + # The URL endpoint for the Identity Provider's SAML SSO. + ssoUrl: URI +} + +# An Invitation for a user to an organization. +type OrganizationInvitation implements Node { + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The email address of the user invited to the organization. + email: String + id: ID! + + # The type of invitation that was sent (e.g. email, user). + invitationType: OrganizationInvitationType! + + # The user who was invited to the organization. + invitee: User + + # The user who created the invitation. + inviter: User! + + # The organization the invite is for + organization: Organization! + + # The user's pending role in the organization (e.g. member, owner). + role: OrganizationInvitationRole! +} + +# The connection type for OrganizationInvitation. +type OrganizationInvitationConnection { + # A list of edges. + edges: [OrganizationInvitationEdge] + + # A list of nodes. + nodes: [OrganizationInvitation] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type OrganizationInvitationEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: OrganizationInvitation +} + +# The possible organization invitation roles. +enum OrganizationInvitationRole { + # The user is invited to be an admin of the organization. + ADMIN + + # The user is invited to be a billing manager of the organization. + BILLING_MANAGER + + # The user is invited to be a direct member of the organization. + DIRECT_MEMBER + + # The user's previous role will be reinstated. + REINSTATE +} + +# The possible organization invitation types. +enum OrganizationInvitationType { + # The invitation was to an email address. + EMAIL + + # The invitation was to an existing user. + USER +} + +# Information about pagination in a connection. +type PageInfo { + # When paginating forwards, the cursor to continue. + endCursor: String + + # When paginating forwards, are there more items? + hasNextPage: Boolean! + + # When paginating backwards, are there more items? + hasPreviousPage: Boolean! + + # When paginating backwards, the cursor to continue. + startCursor: String +} + +# Projects manage issues, pull requests and notes within a project owner. +type Project implements Closable & Node & Updatable { + # The project's description body. + body: String + + # The projects description body rendered to HTML. + bodyHTML: HTML! + + # `true` if the object is closed (definition of closed may depend on type) + closed: Boolean! + + # Identifies the date and time when the object was closed. + closedAt: DateTime + + # List of columns in the project + columns( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ProjectColumnConnection! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The actor who originally created the project. + creator: Actor + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # The project's name. + name: String! + + # The project's number. + number: Int! + + # The project's owner. Currently limited to repositories and organizations. + owner: ProjectOwner! + + # List of pending cards in this project + pendingCards( + # Returns the elements in the list that come after the specified cursor. + after: String + + # A list of archived states to filter the cards by + archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ProjectCardConnection! + + # The HTTP path for this project + resourcePath: URI! + + # Whether the project is open or closed. + state: ProjectState! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this project + url: URI! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! +} + +# A card in a project. +type ProjectCard implements Node { + # The project column this card is associated under. A card may only belong to one + # project column at a time. The column field will be null if the card is created + # in a pending state and has yet to be associated with a column. Once cards are + # associated with a column, they will not become pending in the future. + column: ProjectColumn + + # The card content item + content: ProjectCardItem + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The actor who created this card + creator: Actor + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # Whether the card is archived + isArchived: Boolean! + + # The card note + note: String + + # The project that contains this card. + project: Project! + + # The HTTP path for this card + resourcePath: URI! + + # The state of ProjectCard + state: ProjectCardState + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this card + url: URI! +} + +# The possible archived states of a project card. +enum ProjectCardArchivedState { + # A project card that is archived + ARCHIVED + + # A project card that is not archived + NOT_ARCHIVED +} + +# The connection type for ProjectCard. +type ProjectCardConnection { + # A list of edges. + edges: [ProjectCardEdge] + + # A list of nodes. + nodes: [ProjectCard] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ProjectCardEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ProjectCard +} + +# Types that can be inside Project Cards. +union ProjectCardItem = Issue | PullRequest + +# Various content states of a ProjectCard +enum ProjectCardState { + # The card has content only. + CONTENT_ONLY + + # The card has a note only. + NOTE_ONLY + + # The card is redacted. + REDACTED +} + +# A column inside a project. +type ProjectColumn implements Node { + # List of cards in the column + cards( + # Returns the elements in the list that come after the specified cursor. + after: String + + # A list of archived states to filter the cards by + archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ProjectCardConnection! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # The project column's name. + name: String! + + # The project that contains this column. + project: Project! + + # The semantic purpose of the column + purpose: ProjectColumnPurpose + + # The HTTP path for this project column + resourcePath: URI! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this project column + url: URI! +} + +# The connection type for ProjectColumn. +type ProjectColumnConnection { + # A list of edges. + edges: [ProjectColumnEdge] + + # A list of nodes. + nodes: [ProjectColumn] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ProjectColumnEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ProjectColumn +} + +# The semantic purpose of the column - todo, in progress, or done. +enum ProjectColumnPurpose { + # The column contains cards which are complete + DONE + + # The column contains cards which are currently being worked on + IN_PROGRESS + + # The column contains cards still to be worked on + TODO +} + +# A list of projects associated with the owner. +type ProjectConnection { + # A list of edges. + edges: [ProjectEdge] + + # A list of nodes. + nodes: [Project] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ProjectEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Project +} + +# Ways in which lists of projects can be ordered upon return. +input ProjectOrder { + # The direction in which to order projects by the specified field. + direction: OrderDirection! + + # The field in which to order projects by. + field: ProjectOrderField! +} + +# Properties by which project connections can be ordered. +enum ProjectOrderField { + # Order projects by creation time + CREATED_AT + + # Order projects by name + NAME + + # Order projects by update time + UPDATED_AT +} + +# Represents an owner of a Project. +interface ProjectOwner { + id: ID! + + # Find project by number. + project( + # The project number to find. + number: Int! + ): Project + + # A list of projects under the owner. + projects( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for projects returned from the connection + orderBy: ProjectOrder + + # Query to search projects by, currently only searching by name. + search: String + + # A list of states to filter the projects by. + states: [ProjectState!] + ): ProjectConnection! + + # The HTTP path listing owners projects + projectsResourcePath: URI! + + # The HTTP URL listing owners projects + projectsUrl: URI! + + # Can the current viewer create new projects on this owner. + viewerCanCreateProjects: Boolean! +} + +# State of the project; either 'open' or 'closed' +enum ProjectState { + # The project is closed. + CLOSED + + # The project is open. + OPEN +} + +# A repository protected branch. +type ProtectedBranch implements Node { + # The actor who created this protected branch. + creator: Actor + + # Will new commits pushed to this branch dismiss pull request review approvals. + hasDismissableStaleReviews: Boolean! + + # Are reviews required to update this branch. + hasRequiredReviews: Boolean! + + # Are status checks required to update this branch. + hasRequiredStatusChecks: Boolean! + + # Is pushing to this branch restricted. + hasRestrictedPushes: Boolean! + + # Is dismissal of pull request reviews restricted. + hasRestrictedReviewDismissals: Boolean! + + # Are branches required to be up to date before merging. + hasStrictRequiredStatusChecks: Boolean! + id: ID! + + # Can admins overwrite branch protection. + isAdminEnforced: Boolean! + + # Identifies the name of the protected branch. + name: String! + + # A list push allowances for this protected branch. + pushAllowances( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): PushAllowanceConnection! + + # The repository associated with this protected branch. + repository: Repository! + + # List of required status check contexts that must pass for commits to be accepted to this branch. + requiredStatusCheckContexts: [String] + + # A list review dismissal allowances for this protected branch. + reviewDismissalAllowances( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ReviewDismissalAllowanceConnection! +} + +# The connection type for ProtectedBranch. +type ProtectedBranchConnection { + # A list of edges. + edges: [ProtectedBranchEdge] + + # A list of nodes. + nodes: [ProtectedBranch] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ProtectedBranchEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ProtectedBranch +} + +# A user's public key. +type PublicKey implements Node { + id: ID! + + # The public key string + key: String! +} + +# The connection type for PublicKey. +type PublicKeyConnection { + # A list of edges. + edges: [PublicKeyEdge] + + # A list of nodes. + nodes: [PublicKey] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type PublicKeyEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PublicKey +} + +# A repository pull request. +type PullRequest implements Assignable & Closable & Comment & Labelable & Lockable & Node & Reactable & RepositoryNode & Subscribable & UniformResourceLocatable & Updatable & UpdatableComment { + # Reason that the conversation was locked. + activeLockReason: LockReason + + # The number of additions in this pull request. + additions: Int! + + # A list of Users assigned to this object. + assignees( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # Identifies the base Ref associated with the pull request. + baseRef: Ref + + # Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. + baseRefName: String! + + # Identifies the oid of the base ref associated with the pull request, even if the ref has been deleted. + baseRefOid: GitObjectID! + + # The body as Markdown. + body: String! + + # The body rendered to HTML. + bodyHTML: HTML! + + # The body rendered to text. + bodyText: String! + + # The number of changed files in this pull request. + changedFiles: Int! + + # `true` if the pull request is closed + closed: Boolean! + + # Identifies the date and time when the object was closed. + closedAt: DateTime + + # A list of comments associated with the pull request. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): IssueCommentConnection! + + # A list of commits present in this pull request's head branch not present in the base branch. + commits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): PullRequestCommitConnection! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The number of deletions in this pull request. + deletions: Int! + + # The actor who edited this pull request's body. + editor: Actor + + # Identifies the head Ref associated with the pull request. + headRef: Ref + + # Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. + headRefName: String! + + # Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. + headRefOid: GitObjectID! + + # The repository associated with this pull request's head Ref. + headRepository: Repository + + # The owner of the repository associated with this pull request's head Ref. + headRepositoryOwner: RepositoryOwner + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # The head and base repositories are different. + isCrossRepository: Boolean! + + # A list of labels associated with the object. + labels( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): LabelConnection + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # `true` if the pull request is locked + locked: Boolean! + + # Indicates whether maintainers can modify the pull request. + maintainerCanModify: Boolean! + + # The commit that was created when this pull request was merged. + mergeCommit: Commit + + # Whether or not the pull request can be merged based on the existence of merge conflicts. + mergeable: MergeableState! + + # Whether or not the pull request was merged. + merged: Boolean! + + # The date and time that the pull request was merged. + mergedAt: DateTime + + # The actor who merged the pull request. + mergedBy: Actor + + # Identifies the milestone associated with the pull request. + milestone: Milestone + + # Identifies the pull request number. + number: Int! + + # A list of Users that are participating in the Pull Request conversation. + participants( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # The permalink to the pull request. + permalink: URI! + + # The commit that GitHub automatically generated to test if this pull request + # could be merged. This field will not return a value if the pull request is + # merged, or if the test merge commit is still being generated. See the + # `mergeable` field for more details on the mergeability of the pull request. + potentialMergeCommit: Commit + + # List of project cards associated with this pull request. + projectCards( + # Returns the elements in the list that come after the specified cursor. + after: String + + # A list of archived states to filter the cards by + archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ProjectCardConnection! + + # Identifies when the comment was published at. + publishedAt: DateTime + + # A list of reactions grouped by content left on the subject. + reactionGroups: [ReactionGroup!] + + # A list of Reactions left on the Issue. + reactions( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Allows filtering Reactions by emoji. + content: ReactionContent + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows specifying the order in which reactions are returned. + orderBy: ReactionOrder + ): ReactionConnection! + + # The repository associated with this node. + repository: Repository! + + # The HTTP path for this pull request. + resourcePath: URI! + + # The HTTP path for reverting this pull request. + revertResourcePath: URI! + + # The HTTP URL for reverting this pull request. + revertUrl: URI! + + # A list of review requests associated with the pull request. + reviewRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ReviewRequestConnection + + # A list of reviews associated with the pull request. + reviews( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Filter by author of the review. + author: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # A list of states to filter the reviews. + states: [PullRequestReviewState!] + ): PullRequestReviewConnection + + # Identifies the state of the pull request. + state: PullRequestState! + + # A list of reviewer suggestions based on commit history and past review comments. + suggestedReviewers: [SuggestedReviewer]! + + # A list of events, comments, commits, etc. associated with the pull request. + timeline( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows filtering timeline events by a `since` timestamp. + since: DateTime + ): PullRequestTimelineConnection! + + # A list of events, comments, commits, etc. associated with the pull request. + timelineItems( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Filter timeline items by type. + itemTypes: [PullRequestTimelineItemsItemType!] + + # Returns the last _n_ elements from the list. + last: Int + + # Filter timeline items by a `since` timestamp. + since: DateTime + + # Skips the first _n_ elements in the list. + skip: Int + ): PullRequestTimelineItemsConnection! + + # Identifies the pull request title. + title: String! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this pull request. + url: URI! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Can user react to this subject + viewerCanReact: Boolean! + + # Check if the viewer is able to change their subscription status for the repository. + viewerCanSubscribe: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! + + # Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. + viewerSubscription: SubscriptionState +} + +# Represents a Git commit part of a pull request. +type PullRequestCommit implements Node & UniformResourceLocatable { + # The Git commit object + commit: Commit! + id: ID! + + # The pull request this commit belongs to + pullRequest: PullRequest! + + # The HTTP path for this pull request commit + resourcePath: URI! + + # The HTTP URL for this pull request commit + url: URI! +} + +# Represents a commit comment thread part of a pull request. +type PullRequestCommitCommentThread implements Node & RepositoryNode { + # The comments that exist in this thread. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CommitCommentConnection! + + # The commit the comments were made on. + commit: Commit! + id: ID! + + # The file the comments were made on. + path: String + + # The position in the diff for the commit that the comment was made on. + position: Int + + # The pull request this commit comment thread belongs to + pullRequest: PullRequest! + + # The repository associated with this node. + repository: Repository! +} + +# The connection type for PullRequestCommit. +type PullRequestCommitConnection { + # A list of edges. + edges: [PullRequestCommitEdge] + + # A list of nodes. + nodes: [PullRequestCommit] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type PullRequestCommitEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PullRequestCommit +} + +# The connection type for PullRequest. +type PullRequestConnection { + # A list of edges. + edges: [PullRequestEdge] + + # A list of nodes. + nodes: [PullRequest] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type PullRequestEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PullRequest +} + +# Ways in which lists of issues can be ordered upon return. +input PullRequestOrder { + # The direction in which to order pull requests by the specified field. + direction: OrderDirection! + + # The field in which to order pull requests by. + field: PullRequestOrderField! +} + +# Properties by which pull_requests connections can be ordered. +enum PullRequestOrderField { + # Order pull_requests by creation time + CREATED_AT + + # Order pull_requests by update time + UPDATED_AT +} + +# The possible PubSub channels for a pull request. +enum PullRequestPubSubTopic { + # The channel ID for observing head ref updates. + HEAD_REF + + # The channel ID for marking an pull request as read. + MARKASREAD + + # The channel ID for updating items on the pull request timeline. + TIMELINE + + # The channel ID for observing pull request updates. + UPDATED +} + +# A review object for a given pull request. +type PullRequestReview implements Comment & Deletable & Node & RepositoryNode & Updatable & UpdatableComment { + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # Identifies the pull request review body. + body: String! + + # The body of this review rendered to HTML. + bodyHTML: HTML! + + # The body of this review rendered as plain text. + bodyText: String! + + # A list of review comments for the current pull request review. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): PullRequestReviewCommentConnection! + + # Identifies the commit associated with this pull request review. + commit: Commit + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The actor who edited the comment. + editor: Actor + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # Identifies when the comment was published at. + publishedAt: DateTime + + # Identifies the pull request associated with this pull request review. + pullRequest: PullRequest! + + # The repository associated with this node. + repository: Repository! + + # The HTTP path permalink for this PullRequestReview. + resourcePath: URI! + + # Identifies the current state of the pull request review. + state: PullRequestReviewState! + + # Identifies when the Pull Request Review was submitted + submittedAt: DateTime + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL permalink for this PullRequestReview. + url: URI! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Check if the current viewer can delete this object. + viewerCanDelete: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! +} + +# A review comment associated with a given repository pull request. +type PullRequestReviewComment implements Comment & Deletable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { + # The actor who authored the comment. + author: Actor + + # Author's association with the subject of the comment. + authorAssociation: CommentAuthorAssociation! + + # The comment body of this review comment. + body: String! + + # The comment body of this review comment rendered to HTML. + bodyHTML: HTML! + + # The comment body of this review comment rendered as plain text. + bodyText: String! + + # Identifies the commit associated with the comment. + commit: Commit! + + # Identifies when the comment was created. + createdAt: DateTime! + + # Check if this comment was created via an email reply. + createdViaEmail: Boolean! + + # Identifies the primary key from the database. + databaseId: Int + + # The diff hunk to which the comment applies. + diffHunk: String! + + # Identifies when the comment was created in a draft state. + draftedAt: DateTime! + + # The actor who edited the comment. + editor: Actor + id: ID! + + # Check if this comment was edited and includes an edit with the creation data + includesCreatedEdit: Boolean! + + # The moment the editor made the last edit + lastEditedAt: DateTime + + # Identifies the original commit associated with the comment. + originalCommit: Commit + + # The original line index in the diff to which the comment applies. + originalPosition: Int! + + # The path to which the comment applies. + path: String! + + # The line index in the diff to which the comment applies. + position: Int + + # Identifies when the comment was published at. + publishedAt: DateTime + + # The pull request associated with this review comment. + pullRequest: PullRequest! + + # The pull request review associated with this review comment. + pullRequestReview: PullRequestReview + + # A list of reactions grouped by content left on the subject. + reactionGroups: [ReactionGroup!] + + # A list of Reactions left on the Issue. + reactions( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Allows filtering Reactions by emoji. + content: ReactionContent + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows specifying the order in which reactions are returned. + orderBy: ReactionOrder + ): ReactionConnection! + + # The comment this is a reply to. + replyTo: PullRequestReviewComment + + # The repository associated with this node. + repository: Repository! + + # The HTTP path permalink for this review comment. + resourcePath: URI! + + # Identifies when the comment was last updated. + updatedAt: DateTime! + + # The HTTP URL permalink for this review comment. + url: URI! + + # A list of edits to this content. + userContentEdits( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserContentEditConnection + + # Check if the current viewer can delete this object. + viewerCanDelete: Boolean! + + # Can user react to this subject + viewerCanReact: Boolean! + + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! + + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! + + # Did the viewer author this comment. + viewerDidAuthor: Boolean! +} + +# The connection type for PullRequestReviewComment. +type PullRequestReviewCommentConnection { + # A list of edges. + edges: [PullRequestReviewCommentEdge] + + # A list of nodes. + nodes: [PullRequestReviewComment] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type PullRequestReviewCommentEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PullRequestReviewComment +} + +# The connection type for PullRequestReview. +type PullRequestReviewConnection { + # A list of edges. + edges: [PullRequestReviewEdge] + + # A list of nodes. + nodes: [PullRequestReview] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type PullRequestReviewEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PullRequestReview +} + +# The possible events to perform on a pull request review. +enum PullRequestReviewEvent { + # Submit feedback and approve merging these changes. + APPROVE + + # Submit general feedback without explicit approval. + COMMENT + + # Dismiss review so it now longer effects merging. + DISMISS + + # Submit feedback that must be addressed before merging. + REQUEST_CHANGES +} + +# The possible states of a pull request review. +enum PullRequestReviewState { + # A review allowing the pull request to merge. + APPROVED + + # A review blocking the pull request from merging. + CHANGES_REQUESTED + + # An informational review. + COMMENTED + + # A review that has been dismissed. + DISMISSED + + # A review that has not yet been submitted. + PENDING +} + +# A threaded list of comments for a given pull request. +type PullRequestReviewThread implements Node { + # A list of pull request comments associated with the thread. + comments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): PullRequestReviewCommentConnection! + id: ID! + + # Whether this thread has been resolved + isResolved: Boolean! + + # Identifies the pull request associated with this thread. + pullRequest: PullRequest! + + # Identifies the repository associated with this thread. + repository: Repository! + + # The user who resolved this thread + resolvedBy: User + + # Whether or not the viewer can resolve this thread + viewerCanResolve: Boolean! + + # Whether or not the viewer can unresolve this thread + viewerCanUnresolve: Boolean! +} + +# Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. +type PullRequestRevisionMarker { + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The last commit the viewer has seen. + lastSeenCommit: Commit! + + # The pull request to which the marker belongs. + pullRequest: PullRequest! +} + +# The possible states of a pull request. +enum PullRequestState { + # A pull request that has been closed without being merged. + CLOSED + + # A pull request that has been closed by being merged. + MERGED + + # A pull request that is still open. + OPEN +} + +# The connection type for PullRequestTimelineItem. +type PullRequestTimelineConnection { + # A list of edges. + edges: [PullRequestTimelineItemEdge] + + # A list of nodes. + nodes: [PullRequestTimelineItem] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An item in an pull request timeline +union PullRequestTimelineItem = AssignedEvent | BaseRefForcePushedEvent | ClosedEvent | Commit | CommitCommentThread | CrossReferencedEvent | DemilestonedEvent | DeployedEvent | DeploymentEnvironmentChangedEvent | HeadRefDeletedEvent | HeadRefForcePushedEvent | HeadRefRestoredEvent | IssueComment | LabeledEvent | LockedEvent | MergedEvent | MilestonedEvent | PullRequestReview | PullRequestReviewComment | PullRequestReviewThread | ReferencedEvent | RenamedTitleEvent | ReopenedEvent | ReviewDismissedEvent | ReviewRequestRemovedEvent | ReviewRequestedEvent | SubscribedEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnsubscribedEvent + +# An edge in a connection. +type PullRequestTimelineItemEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PullRequestTimelineItem +} + +# An item in a pull request timeline +union PullRequestTimelineItems = AddedToProjectEvent | AssignedEvent | BaseRefChangedEvent | BaseRefForcePushedEvent | ClosedEvent | CommentDeletedEvent | ConvertedNoteToIssueEvent | CrossReferencedEvent | DemilestonedEvent | DeployedEvent | DeploymentEnvironmentChangedEvent | HeadRefDeletedEvent | HeadRefForcePushedEvent | HeadRefRestoredEvent | IssueComment | LabeledEvent | LockedEvent | MentionedEvent | MergedEvent | MilestonedEvent | MovedColumnsInProjectEvent | PullRequestCommit | PullRequestCommitCommentThread | PullRequestReview | PullRequestReviewThread | PullRequestRevisionMarker | ReferencedEvent | RemovedFromProjectEvent | RenamedTitleEvent | ReopenedEvent | ReviewDismissedEvent | ReviewRequestRemovedEvent | ReviewRequestedEvent | SubscribedEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnsubscribedEvent + +# The connection type for PullRequestTimelineItems. +type PullRequestTimelineItemsConnection { + # A list of edges. + edges: [PullRequestTimelineItemsEdge] + + # Identifies the count of items after applying `before` and `after` filters. + filteredCount: Int! + + # A list of nodes. + nodes: [PullRequestTimelineItems] + + # Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing. + pageCount: Int! + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! + + # Identifies the date and time when the timeline was last updated. + updatedAt: DateTime! +} + +# An edge in a connection. +type PullRequestTimelineItemsEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PullRequestTimelineItems +} + +# The possible item types found in a timeline. +enum PullRequestTimelineItemsItemType { + # Represents a 'added_to_project' event on a given issue or pull request. + ADDED_TO_PROJECT_EVENT + + # Represents an 'assigned' event on any assignable object. + ASSIGNED_EVENT + + # Represents a 'base_ref_changed' event on a given issue or pull request. + BASE_REF_CHANGED_EVENT + + # Represents a 'base_ref_force_pushed' event on a given pull request. + BASE_REF_FORCE_PUSHED_EVENT + + # Represents a 'closed' event on any `Closable`. + CLOSED_EVENT + + # Represents a 'comment_deleted' event on a given issue or pull request. + COMMENT_DELETED_EVENT + + # Represents a 'converted_note_to_issue' event on a given issue or pull request. + CONVERTED_NOTE_TO_ISSUE_EVENT + + # Represents a mention made by one issue or pull request to another. + CROSS_REFERENCED_EVENT + + # Represents a 'demilestoned' event on a given issue or pull request. + DEMILESTONED_EVENT + + # Represents a 'deployed' event on a given pull request. + DEPLOYED_EVENT + + # Represents a 'deployment_environment_changed' event on a given pull request. + DEPLOYMENT_ENVIRONMENT_CHANGED_EVENT + + # Represents a 'head_ref_deleted' event on a given pull request. + HEAD_REF_DELETED_EVENT + + # Represents a 'head_ref_force_pushed' event on a given pull request. + HEAD_REF_FORCE_PUSHED_EVENT + + # Represents a 'head_ref_restored' event on a given pull request. + HEAD_REF_RESTORED_EVENT + + # Represents a comment on an Issue. + ISSUE_COMMENT + + # Represents a 'labeled' event on a given issue or pull request. + LABELED_EVENT + + # Represents a 'locked' event on a given issue or pull request. + LOCKED_EVENT + + # Represents a 'marked_as_duplicate' event on a given issue or pull request. + MARKED_AS_DUPLICATE_EVENT + + # Represents a 'mentioned' event on a given issue or pull request. + MENTIONED_EVENT + + # Represents a 'merged' event on a given pull request. + MERGED_EVENT + + # Represents a 'milestoned' event on a given issue or pull request. + MILESTONED_EVENT + + # Represents a 'moved_columns_in_project' event on a given issue or pull request. + MOVED_COLUMNS_IN_PROJECT_EVENT + + # Represents a Git commit part of a pull request. + PULL_REQUEST_COMMIT + + # Represents a commit comment thread part of a pull request. + PULL_REQUEST_COMMIT_COMMENT_THREAD + + # A review object for a given pull request. + PULL_REQUEST_REVIEW + + # A threaded list of comments for a given pull request. + PULL_REQUEST_REVIEW_THREAD + + # Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. + PULL_REQUEST_REVISION_MARKER + + # Represents a 'referenced' event on a given `ReferencedSubject`. + REFERENCED_EVENT + + # Represents a 'removed_from_project' event on a given issue or pull request. + REMOVED_FROM_PROJECT_EVENT + + # Represents a 'renamed' event on a given issue or pull request + RENAMED_TITLE_EVENT + + # Represents a 'reopened' event on any `Closable`. + REOPENED_EVENT + + # Represents a 'review_dismissed' event on a given issue or pull request. + REVIEW_DISMISSED_EVENT + + # Represents an 'review_requested' event on a given pull request. + REVIEW_REQUESTED_EVENT + + # Represents an 'review_request_removed' event on a given pull request. + REVIEW_REQUEST_REMOVED_EVENT + + # Represents a 'subscribed' event on a given `Subscribable`. + SUBSCRIBED_EVENT + + # Represents an 'unassigned' event on any assignable object. + UNASSIGNED_EVENT + + # Represents an 'unlabeled' event on a given issue or pull request. + UNLABELED_EVENT + + # Represents an 'unlocked' event on a given issue or pull request. + UNLOCKED_EVENT + + # Represents an 'unmarked_as_duplicate' event on a given issue or pull request. + UNMARKED_AS_DUPLICATE_EVENT + + # Represents an 'unsubscribed' event on a given `Subscribable`. + UNSUBSCRIBED_EVENT +} + +# A Git push. +type Push implements Node { + id: ID! + + # The SHA after the push + nextSha: GitObjectID + + # The permalink for this push. + permalink: URI! + + # The SHA before the push + previousSha: GitObjectID + + # The user who pushed + pusher: User! + + # The repository that was pushed to + repository: Repository! +} + +# A team or user who has the ability to push to a protected branch. +type PushAllowance implements Node { + # The actor that can push. + actor: PushAllowanceActor + id: ID! + + # Identifies the protected branch associated with the allowed user or team. + protectedBranch: ProtectedBranch! +} + +# Types that can be an actor. +union PushAllowanceActor = Team | User + +# The connection type for PushAllowance. +type PushAllowanceConnection { + # A list of edges. + edges: [PushAllowanceEdge] + + # A list of nodes. + nodes: [PushAllowance] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type PushAllowanceEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: PushAllowance +} + +# The query root of GitHub's GraphQL interface. +type Query { + # Look up a code of conduct by its key + codeOfConduct( + # The code of conduct's key + key: String! + ): CodeOfConduct + + # Look up a code of conduct by its key + codesOfConduct: [CodeOfConduct] + + # Look up an open source license by its key + license( + # The license's downcased SPDX ID + key: String! + ): License + + # Return a list of known open source licenses + licenses: [License]! + + # Get alphabetically sorted list of Marketplace categories + marketplaceCategories( + # Exclude categories with no listings. + excludeEmpty: Boolean + + # Exclude subcategories + excludeSubcategories: Boolean + + # Return only the specified categories. + includeCategories: [String!] + ): [MarketplaceCategory!]! + + # Look up a Marketplace category by its slug. + marketplaceCategory( + # The URL slug of the category. + slug: String! + + # Also check topic aliases for the category slug + useTopicAliases: Boolean + ): MarketplaceCategory + + # Look up a single Marketplace listing + marketplaceListing( + # Select the listing that matches this slug. It's the short name of the listing used in its URL. + slug: String! + ): MarketplaceListing + + # Look up Marketplace listings + marketplaceListings( + # Select listings that can be administered by the specified user. + adminId: ID + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Select listings visible to the viewer even if they are not approved. If omitted or + # false, only approved listings will be returned. + allStates: Boolean + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Select only listings with the given category. + categorySlug: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Select listings for products owned by the specified organization. + organizationId: ID + + # Select only listings where the primary category matches the given category slug. + primaryCategoryOnly: Boolean = false + + # Select the listings with these slugs, if they are visible to the viewer. + slugs: [String] + + # Also check topic aliases for the category slug + useTopicAliases: Boolean + + # Select listings to which user has admin access. If omitted, listings visible to the + # viewer are returned. + viewerCanAdmin: Boolean + + # Select only listings that offer a free trial. + withFreeTrialsOnly: Boolean = false + ): MarketplaceListingConnection! + + # Return information about the GitHub instance + meta: GitHubMetadata! + + # Fetches an object given its ID. + node( + # ID of the object. + id: ID! + ): Node + + # Lookup nodes by a list of IDs. + nodes( + # The list of node IDs. + ids: [ID!]! + ): [Node]! + + # Lookup a organization by login. + organization( + # The organization's login. + login: String! + ): Organization + + # The client's rate limit information. + rateLimit( + # If true, calculate the cost for the query without evaluating it + dryRun: Boolean = false + ): RateLimit + + # Hack to workaround https://github.com/facebook/relay/issues/112 re-exposing the root query object + relay: Query! + + # Lookup a given repository by the owner and repository name. + repository( + # The name of the repository + name: String! + + # The login field of a user or organization + owner: String! + ): Repository + + # Lookup a repository owner (ie. either a User or an Organization) by login. + repositoryOwner( + # The username to lookup the owner by. + login: String! + ): RepositoryOwner + + # Lookup resource by a URL. + resource( + # The URL. + url: URI! + ): UniformResourceLocatable + + # Perform a search across resources. + search( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # The search string to look for. + query: String! + + # The types of search items to search within. + type: SearchType! + ): SearchResultItemConnection! + + # Look up a topic by name. + topic( + # The topic's name. + name: String! + ): Topic + + # Lookup a user by login. + user( + # The user's login. + login: String! + ): User + + # The currently authenticated user. + viewer: User! +} + +# Represents the client's rate limit. +type RateLimit { + # The point cost for the current query counting against the rate limit. + cost: Int! + + # The maximum number of points the client is permitted to consume in a 60 minute window. + limit: Int! + + # The maximum number of nodes this query may return + nodeCount: Int! + + # The number of points remaining in the current rate limit window. + remaining: Int! + + # The time at which the current rate limit window resets in UTC epoch seconds. + resetAt: DateTime! +} + +# Represents a subject that can be reacted on. +interface Reactable { + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # A list of reactions grouped by content left on the subject. + reactionGroups: [ReactionGroup!] + + # A list of Reactions left on the Issue. + reactions( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Allows filtering Reactions by emoji. + content: ReactionContent + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Allows specifying the order in which reactions are returned. + orderBy: ReactionOrder + ): ReactionConnection! + + # Can user react to this subject + viewerCanReact: Boolean! +} + +# The connection type for User. +type ReactingUserConnection { + # A list of edges. + edges: [ReactingUserEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a user that's made a reaction. +type ReactingUserEdge { + # A cursor for use in pagination. + cursor: String! + node: User! + + # The moment when the user made the reaction. + reactedAt: DateTime! +} + +# An emoji reaction to a particular piece of content. +type Reaction implements Node { + # Identifies the emoji reaction. + content: ReactionContent! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # The reactable piece of content + reactable: Reactable! + + # Identifies the user who created this reaction. + user: User +} + +# A list of reactions that have been left on the subject. +type ReactionConnection { + # A list of edges. + edges: [ReactionEdge] + + # A list of nodes. + nodes: [Reaction] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! + + # Whether or not the authenticated user has left a reaction on the subject. + viewerHasReacted: Boolean! +} + +# Emojis that can be attached to Issues, Pull Requests and Comments. +enum ReactionContent { + # Represents the 😕 emoji. + CONFUSED + + # Represents the â¤ï¸ emoji. + HEART + + # Represents the 🎉 emoji. + HOORAY + + # Represents the 😄 emoji. + LAUGH + + # Represents the 👎 emoji. + THUMBS_DOWN + + # Represents the 👠emoji. + THUMBS_UP +} + +# An edge in a connection. +type ReactionEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Reaction +} + +# A group of emoji reactions to a particular piece of content. +type ReactionGroup { + # Identifies the emoji reaction. + content: ReactionContent! + + # Identifies when the reaction was created. + createdAt: DateTime + + # The subject that was reacted to. + subject: Reactable! + + # Users who have reacted to the reaction subject with the emotion represented by this reaction group + users( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ReactingUserConnection! + + # Whether or not the authenticated user has left a reaction on the subject. + viewerHasReacted: Boolean! +} + +# Ways in which lists of reactions can be ordered upon return. +input ReactionOrder { + # The direction in which to order reactions by the specified field. + direction: OrderDirection! + + # The field in which to order reactions by. + field: ReactionOrderField! +} + +# A list of fields that reactions can be ordered by. +enum ReactionOrderField { + # Allows ordering a list of reactions by when they were created. + CREATED_AT +} + +# Represents a Git reference. +type Ref implements Node { + # A list of pull requests with this ref as the head ref. + associatedPullRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # The base ref name to filter the pull requests by. + baseRefName: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # The head ref name to filter the pull requests by. + headRefName: String + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for pull requests returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the pull requests by. + states: [PullRequestState!] + ): PullRequestConnection! + id: ID! + + # The ref name. + name: String! + + # The ref's prefix, such as `refs/heads/` or `refs/tags/`. + prefix: String! + + # The repository the ref belongs to. + repository: Repository! + + # The object the ref points to. + target: GitObject! +} + +# The connection type for Ref. +type RefConnection { + # A list of edges. + edges: [RefEdge] + + # A list of nodes. + nodes: [Ref] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type RefEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Ref +} + +# Ways in which lists of git refs can be ordered upon return. +input RefOrder { + # The direction in which to order refs by the specified field. + direction: OrderDirection! + + # The field in which to order refs by. + field: RefOrderField! +} + +# Properties by which ref connections can be ordered. +enum RefOrderField { + # Order refs by their alphanumeric name + ALPHABETICAL + + # Order refs by underlying commit date if the ref prefix is refs/tags/ + TAG_COMMIT_DATE +} + +# Represents a 'referenced' event on a given `ReferencedSubject`. +type ReferencedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the commit associated with the 'referenced' event. + commit: Commit + + # Identifies the repository associated with the 'referenced' event. + commitRepository: Repository! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Reference originated in a different repository. + isCrossRepository: Boolean! + + # Checks if the commit message itself references the subject. Can be false in the case of a commit comment reference. + isDirectReference: Boolean! + + # Object referenced by event. + subject: ReferencedSubject! +} + +# Any referencable object +union ReferencedSubject = Issue | PullRequest + +# Represents an owner of a registry package. +interface RegistryPackageOwner { + id: ID! +} + +# Represents an interface to search packages on an object. +interface RegistryPackageSearch { + id: ID! +} + +# A release contains the content for a release. +type Release implements Node & UniformResourceLocatable { + # The author of the release + author: User + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the description of the release. + description: String + id: ID! + + # Whether or not the release is a draft + isDraft: Boolean! + + # Whether or not the release is a prerelease + isPrerelease: Boolean! + + # Identifies the title of the release. + name: String + + # Identifies the date and time when the release was created. + publishedAt: DateTime + + # List of releases assets which are dependent on this release. + releaseAssets( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # A list of names to filter the assets by. + name: String + ): ReleaseAssetConnection! + + # The HTTP path for this issue + resourcePath: URI! + + # The Git tag the release points to + tag: Ref + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this issue + url: URI! +} + +# A release asset contains the content for a release asset. +type ReleaseAsset implements Node { + # The asset's content-type + contentType: String! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The number of times this asset was downloaded + downloadCount: Int! + + # Identifies the URL where you can download the release asset via the browser. + downloadUrl: URI! + id: ID! + + # Identifies the title of the release asset. + name: String! + + # Release that the asset is associated with + release: Release + + # The size (in bytes) of the asset + size: Int! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The user that performed the upload + uploadedBy: User! + + # Identifies the URL of the release asset. + url: URI! +} + +# The connection type for ReleaseAsset. +type ReleaseAssetConnection { + # A list of edges. + edges: [ReleaseAssetEdge] + + # A list of nodes. + nodes: [ReleaseAsset] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ReleaseAssetEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ReleaseAsset +} + +# The connection type for Release. +type ReleaseConnection { + # A list of edges. + edges: [ReleaseEdge] + + # A list of nodes. + nodes: [Release] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ReleaseEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Release +} + +# Ways in which lists of releases can be ordered upon return. +input ReleaseOrder { + # The direction in which to order releases by the specified field. + direction: OrderDirection! + + # The field in which to order releases by. + field: ReleaseOrderField! +} + +# Properties by which release connections can be ordered. +enum ReleaseOrderField { + # Order releases by creation time + CREATED_AT + + # Order releases alphabetically by name + NAME +} + +# Autogenerated input type of RemoveAssigneesFromAssignable +input RemoveAssigneesFromAssignableInput { + # The id of the assignable object to remove assignees from. + assignableId: ID! + + # The id of users to remove as assignees. + assigneeIds: [ID!]! + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated return type of RemoveAssigneesFromAssignable +type RemoveAssigneesFromAssignablePayload { + # The item that was unassigned. + assignable: Assignable + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of RemoveLabelsFromLabelable +input RemoveLabelsFromLabelableInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ids of labels to remove. + labelIds: [ID!]! + + # The id of the Labelable to remove labels from. + labelableId: ID! +} + +# Autogenerated return type of RemoveLabelsFromLabelable +type RemoveLabelsFromLabelablePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Labelable the labels were removed from. + labelable: Labelable +} + +# Autogenerated input type of RemoveOutsideCollaborator +input RemoveOutsideCollaboratorInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ID of the organization to remove the outside collaborator from. + organizationId: ID! + + # The ID of the outside collaborator to remove. + userId: ID! +} + +# Autogenerated return type of RemoveOutsideCollaborator +type RemoveOutsideCollaboratorPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The user that was removed as an outside collaborator. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `removedUser` will change from `User!` to `User`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + removedUser: User! +} + +# Autogenerated input type of RemoveReaction +input RemoveReactionInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of the emoji reaction to remove. + content: ReactionContent! + + # The Node ID of the subject to modify. + subjectId: ID! +} + +# Autogenerated return type of RemoveReaction +type RemoveReactionPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The reaction object. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `reaction` will change from `Reaction!` to `Reaction`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + reaction: Reaction! + + # The reactable subject. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `subject` will change from `Reactable!` to `Reactable`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + subject: Reactable! +} + +# Autogenerated input type of RemoveStar +input RemoveStarInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Starrable ID to unstar. + starrableId: ID! +} + +# Autogenerated return type of RemoveStar +type RemoveStarPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The starrable. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `starrable` will change from `Starrable!` to `Starrable`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + starrable: Starrable! +} + +# Represents a 'removed_from_project' event on a given issue or pull request. +type RemovedFromProjectEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! +} + +# Represents a 'renamed' event on a given issue or pull request +type RenamedTitleEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the current title of the issue or pull request. + currentTitle: String! + id: ID! + + # Identifies the previous title of the issue or pull request. + previousTitle: String! + + # Subject that was renamed. + subject: RenamedTitleSubject! +} + +# An object which has a renamable title +union RenamedTitleSubject = Issue | PullRequest + +# Autogenerated input type of ReopenIssue +input ReopenIssueInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # ID of the issue to be opened. + issueId: ID! +} + +# Autogenerated return type of ReopenIssue +type ReopenIssuePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The issue that was opened. + issue: Issue +} + +# Represents a 'reopened' event on any `Closable`. +type ReopenedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Object that was reopened. + closable: Closable! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! +} + +# A repository contains the content for a project. +type Repository implements Node & ProjectOwner & RegistryPackageOwner & RepositoryInfo & Starrable & Subscribable & UniformResourceLocatable { + # A list of users that can be assigned to issues in this repository. + assignableUsers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # Returns the code of conduct for this repository + codeOfConduct: CodeOfConduct + + # A list of collaborators associated with the repository. + collaborators( + # Collaborators affiliation level with a repository. + affiliation: CollaboratorAffiliation + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): RepositoryCollaboratorConnection + + # A list of commit comments associated with the repository. + commitComments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CommitCommentConnection! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + + # The Ref associated with the repository's default branch. + defaultBranchRef: Ref + + # A list of deploy keys that are on this repository. + deployKeys( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): DeployKeyConnection! + + # Deployments associated with the repository + deployments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Environments to list deployments for + environments: [String!] + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): DeploymentConnection! + + # The description of the repository. + description: String + + # The description of the repository rendered to HTML. + descriptionHTML: HTML! + + # The number of kilobytes this repository occupies on disk. + diskUsage: Int + + # Returns how many forks there are of this repository in the whole network. + forkCount: Int! + + # A list of direct forked repositories. + forks( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # Indicates if the repository has issues feature enabled. + hasIssuesEnabled: Boolean! + + # Indicates if the repository has wiki feature enabled. + hasWikiEnabled: Boolean! + + # The repository's URL. + homepageUrl: URI + id: ID! + + # Indicates if the repository is unmaintained. + isArchived: Boolean! + + # Identifies if the repository is a fork. + isFork: Boolean! + + # Indicates if the repository has been locked or not. + isLocked: Boolean! + + # Identifies if the repository is a mirror. + isMirror: Boolean! + + # Identifies if the repository is private. + isPrivate: Boolean! + + # Returns a single issue from the current repository by number. + issue( + # The number for the issue to be returned. + number: Int! + ): Issue + + # Returns a single issue-like object from the current repository by number. + issueOrPullRequest( + # The number for the issue to be returned. + number: Int! + ): IssueOrPullRequest + + # A list of issues that have been opened in the repository. + issues( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Filtering options for issues returned from the connection. + filterBy: IssueFilters + + # Returns the first _n_ elements from the list. + first: Int + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for issues returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the issues by. + states: [IssueState!] + ): IssueConnection! + + # Returns a single label by name + label( + # Label name + name: String! + ): Label + + # A list of labels associated with the repository. + labels( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # If provided, searches labels by name and description. + query: String + ): LabelConnection + + # A list containing a breakdown of the language composition of the repository. + languages( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: LanguageOrder + ): LanguageConnection + + # The license associated with the repository + licenseInfo: License + + # The reason the repository has been locked. + lockReason: RepositoryLockReason + + # A list of Users that can be mentioned in the context of the repository. + mentionableUsers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! + + # Whether or not PRs are merged with a merge commit on this repository. + mergeCommitAllowed: Boolean! + + # Returns a single milestone from the current repository by number. + milestone( + # The number for the milestone to be returned. + number: Int! + ): Milestone + + # A list of milestones associated with the repository. + milestones( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for milestones. + orderBy: MilestoneOrder + + # Filter by the state of the milestones. + states: [MilestoneState!] + ): MilestoneConnection + + # The repository's original mirror URL. + mirrorUrl: URI + + # The name of the repository. + name: String! + + # The repository's name with owner. + nameWithOwner: String! + + # A Git object in the repository + object( + # A Git revision expression suitable for rev-parse + expression: String + + # The Git object ID + oid: GitObjectID + ): GitObject + + # The User owner of the repository. + owner: RepositoryOwner! + + # The repository parent, if this is a fork. + parent: Repository + + # The primary language of the repository's code. + primaryLanguage: Language + + # Find project by number. + project( + # The project number to find. + number: Int! + ): Project + + # A list of projects under the owner. + projects( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for projects returned from the connection + orderBy: ProjectOrder + + # Query to search projects by, currently only searching by name. + search: String + + # A list of states to filter the projects by. + states: [ProjectState!] + ): ProjectConnection! + + # The HTTP path listing the repository's projects + projectsResourcePath: URI! + + # The HTTP URL listing the repository's projects + projectsUrl: URI! + + # A list of protected branches that are on this repository. + protectedBranches( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): ProtectedBranchConnection! + + # Returns a single pull request from the current repository by number. + pullRequest( + # The number for the pull request to be returned. + number: Int! + ): PullRequest + + # A list of pull requests that have been opened in the repository. + pullRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # The base ref name to filter the pull requests by. + baseRefName: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # The head ref name to filter the pull requests by. + headRefName: String + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for pull requests returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the pull requests by. + states: [PullRequestState!] + ): PullRequestConnection! + + # Identifies when the repository was last pushed to. + pushedAt: DateTime + + # Whether or not rebase-merging is enabled on this repository. + rebaseMergeAllowed: Boolean! + + # Fetch a given ref from the repository + ref( + # The ref to retrieve. Fully qualified matches are checked in order + # (`refs/heads/master`) before falling back onto checks for short name matches (`master`). + qualifiedName: String! + ): Ref + + # Fetch a list of refs from the repository + refs( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # DEPRECATED: use orderBy. The ordering direction. + direction: OrderDirection + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for refs returned from the connection. + orderBy: RefOrder + + # A ref name prefix like `refs/heads/`, `refs/tags/`, etc. + refPrefix: String! + ): RefConnection + + # Lookup a single release given various criteria. + release( + # The name of the Tag the Release was created from + tagName: String! + ): Release + + # List of releases which are dependent on this repository. + releases( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: ReleaseOrder + ): ReleaseConnection! + + # A list of applied repository-topic associations for this repository. + repositoryTopics( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): RepositoryTopicConnection! + + # The HTTP path for this repository + resourcePath: URI! + + # A description of the repository, rendered to HTML without any links in it. + shortDescriptionHTML( + # How many characters to return. + limit: Int = 200 + ): HTML! + + # Whether or not squash-merging is enabled on this repository. + squashMergeAllowed: Boolean! + + # The SSH URL to clone this repository + sshUrl: GitSSHRemote! + + # A list of users who have starred this starrable. + stargazers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: StarOrder + ): StargazerConnection! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this repository + url: URI! + + # Indicates whether the viewer has admin permissions on this repository. + viewerCanAdminister: Boolean! + + # Can the current viewer create new projects on this owner. + viewerCanCreateProjects: Boolean! + + # Check if the viewer is able to change their subscription status for the repository. + viewerCanSubscribe: Boolean! + + # Indicates whether the viewer can update the topics of this repository. + viewerCanUpdateTopics: Boolean! + + # Returns a boolean indicating whether the viewing user has starred this starrable. + viewerHasStarred: Boolean! + + # The users permission level on the repository. Will return null if authenticated as an GitHub App. + viewerPermission: RepositoryPermission + + # Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. + viewerSubscription: SubscriptionState + + # A list of users watching the repository. + watchers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): UserConnection! +} + +# The affiliation of a user to a repository +enum RepositoryAffiliation { + # Repositories that the user has been added to as a collaborator. + COLLABORATOR + + # Repositories that the user has access to through being a member of an + # organization. This includes every repository on every team that the user is on. + ORGANIZATION_MEMBER + + # Repositories that are owned by the authenticated user. + OWNER +} + +# The affiliation type between collaborator and repository. +enum RepositoryCollaboratorAffiliation { + # All collaborators of the repository. + ALL + + # All outside collaborators of an organization-owned repository. + OUTSIDE +} + +# The connection type for User. +type RepositoryCollaboratorConnection { + # A list of edges. + edges: [RepositoryCollaboratorEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a user who is a collaborator of a repository. +type RepositoryCollaboratorEdge { + # A cursor for use in pagination. + cursor: String! + node: User! + + # The permission the user has on the repository. + permission: RepositoryPermission! +} + +# A list of repositories owned by the subject. +type RepositoryConnection { + # A list of edges. + edges: [RepositoryEdge] + + # A list of nodes. + nodes: [Repository] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! + + # The total size in kilobytes of all repositories in the connection. + totalDiskUsage: Int! +} + +# The reason a repository is listed as 'contributed'. +enum RepositoryContributionType { + # Created a commit + COMMIT + + # Created an issue + ISSUE + + # Created a pull request + PULL_REQUEST + + # Reviewed a pull request + PULL_REQUEST_REVIEW + + # Created the repository + REPOSITORY +} + +# An edge in a connection. +type RepositoryEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Repository +} + +# A subset of repository info. +interface RepositoryInfo { + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The description of the repository. + description: String + + # The description of the repository rendered to HTML. + descriptionHTML: HTML! + + # Returns how many forks there are of this repository in the whole network. + forkCount: Int! + + # Indicates if the repository has issues feature enabled. + hasIssuesEnabled: Boolean! + + # Indicates if the repository has wiki feature enabled. + hasWikiEnabled: Boolean! + + # The repository's URL. + homepageUrl: URI + + # Indicates if the repository is unmaintained. + isArchived: Boolean! + + # Identifies if the repository is a fork. + isFork: Boolean! + + # Indicates if the repository has been locked or not. + isLocked: Boolean! + + # Identifies if the repository is a mirror. + isMirror: Boolean! + + # Identifies if the repository is private. + isPrivate: Boolean! + + # The license associated with the repository + licenseInfo: License + + # The reason the repository has been locked. + lockReason: RepositoryLockReason + + # The repository's original mirror URL. + mirrorUrl: URI + + # The name of the repository. + name: String! + + # The repository's name with owner. + nameWithOwner: String! + + # The User owner of the repository. + owner: RepositoryOwner! + + # Identifies when the repository was last pushed to. + pushedAt: DateTime + + # The HTTP path for this repository + resourcePath: URI! + + # A description of the repository, rendered to HTML without any links in it. + shortDescriptionHTML( + # How many characters to return. + limit: Int = 200 + ): HTML! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this repository + url: URI! +} + +# An invitation for a user to be added to a repository. +type RepositoryInvitation implements Node { + id: ID! + + # The user who received the invitation. + invitee: User! + + # The user who created the invitation. + inviter: User! + + # The permission granted on this repository by this invitation. + permission: RepositoryPermission! + + # The Repository the user is invited to. + repository: RepositoryInfo +} + +# An edge in a connection. +type RepositoryInvitationEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: RepositoryInvitation +} + +# The possible reasons a given repository could be in a locked state. +enum RepositoryLockReason { + # The repository is locked due to a billing related reason. + BILLING + + # The repository is locked due to a migration. + MIGRATING + + # The repository is locked due to a move. + MOVING + + # The repository is locked due to a rename. + RENAME +} + +# Represents a object that belongs to a repository. +interface RepositoryNode { + # The repository associated with this node. + repository: Repository! +} + +# Ordering options for repository connections +input RepositoryOrder { + # The ordering direction. + direction: OrderDirection! + + # The field to order repositories by. + field: RepositoryOrderField! +} + +# Properties by which repository connections can be ordered. +enum RepositoryOrderField { + # Order repositories by creation time + CREATED_AT + + # Order repositories by name + NAME + + # Order repositories by push time + PUSHED_AT + + # Order repositories by number of stargazers + STARGAZERS + + # Order repositories by update time + UPDATED_AT +} + +# Represents an owner of a Repository. +interface RepositoryOwner { + # A URL pointing to the owner's public avatar. + avatarUrl( + # The size of the resulting square image. + size: Int + ): URI! + id: ID! + + # The username used to login. + login: String! + + # A list of repositories this user has pinned to their profile + pinnedRepositories( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # A list of repositories that the user owns. + repositories( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they are forks of another repository + isFork: Boolean + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # Find Repository. + repository( + # Name of Repository to find. + name: String! + ): Repository + + # The HTTP URL for the owner. + resourcePath: URI! + + # The HTTP URL for the owner. + url: URI! +} + +# The access level to a repository +enum RepositoryPermission { + # Can read, clone, push, and add collaborators + ADMIN + + # Can read and clone + READ + + # Can read, clone and push + WRITE +} + +# The privacy of a repository +enum RepositoryPrivacy { + # Private + PRIVATE + + # Public + PUBLIC +} + +# A repository-topic connects a repository to a topic. +type RepositoryTopic implements Node & UniformResourceLocatable { + id: ID! + + # The HTTP path for this repository-topic. + resourcePath: URI! + + # The topic. + topic: Topic! + + # The HTTP URL for this repository-topic. + url: URI! +} + +# The connection type for RepositoryTopic. +type RepositoryTopicConnection { + # A list of edges. + edges: [RepositoryTopicEdge] + + # A list of nodes. + nodes: [RepositoryTopic] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type RepositoryTopicEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: RepositoryTopic +} + +# Autogenerated input type of RequestReviews +input RequestReviewsInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the pull request to modify. + pullRequestId: ID! + + # The Node IDs of the team to request. + teamIds: [ID!] + + # Add users to the set rather than replace. + union: Boolean + + # The Node IDs of the user to request. + userIds: [ID!] +} + +# Autogenerated return type of RequestReviews +type RequestReviewsPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The pull request that is getting requests. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequest` will change from `PullRequest!` to `PullRequest`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequest: PullRequest! + + # The edge from the pull request to the requested reviewers. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `requestedReviewersEdge` will change from `UserEdge!` to `UserEdge`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + requestedReviewersEdge: UserEdge! +} + +# The possible states that can be requested when creating a check run. +enum RequestableCheckStatusState { + # The check suite or run has been completed. + COMPLETED + + # The check suite or run is in progress. + IN_PROGRESS + + # The check suite or run has been queued. + QUEUED +} + +# Types that can be requested reviewers. +union RequestedReviewer = Team | User + +# Autogenerated input type of RerequestCheckSuite +input RerequestCheckSuiteInput { + # The Node ID of the check suite. + checkSuiteId: ID! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the repository. + repositoryId: ID! +} + +# Autogenerated return type of RerequestCheckSuite +type RerequestCheckSuitePayload { + # The requested check suite. + checkSuite: CheckSuite + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of ResolveReviewThread +input ResolveReviewThreadInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ID of the thread to resolve + threadId: ID! +} + +# Autogenerated return type of ResolveReviewThread +type ResolveReviewThreadPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The thread to resolve. + thread: PullRequestReviewThread +} + +# A team or user who has the ability to dismiss a review on a protected branch. +type ReviewDismissalAllowance implements Node { + # The actor that can dismiss. + actor: ReviewDismissalAllowanceActor + id: ID! + + # Identifies the protected branch associated with the allowed user or team. + protectedBranch: ProtectedBranch! +} + +# Types that can be an actor. +union ReviewDismissalAllowanceActor = Team | User + +# The connection type for ReviewDismissalAllowance. +type ReviewDismissalAllowanceConnection { + # A list of edges. + edges: [ReviewDismissalAllowanceEdge] + + # A list of nodes. + nodes: [ReviewDismissalAllowance] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ReviewDismissalAllowanceEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ReviewDismissalAllowance +} + +# Represents a 'review_dismissed' event on a given issue or pull request. +type ReviewDismissedEvent implements Node & UniformResourceLocatable { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # Identifies the message associated with the 'review_dismissed' event. + message: String! + + # The message associated with the event, rendered to HTML. + messageHtml: HTML! + + # Identifies the previous state of the review with the 'review_dismissed' event. + previousReviewState: PullRequestReviewState! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # Identifies the commit which caused the review to become stale. + pullRequestCommit: PullRequestCommit + + # The HTTP path for this review dismissed event. + resourcePath: URI! + + # Identifies the review associated with the 'review_dismissed' event. + review: PullRequestReview + + # The HTTP URL for this review dismissed event. + url: URI! +} + +# A request for a user to review a pull request. +type ReviewRequest implements Node { + # Identifies the primary key from the database. + databaseId: Int + id: ID! + + # Identifies the pull request associated with this review request. + pullRequest: PullRequest! + + # The reviewer that is requested. + requestedReviewer: RequestedReviewer +} + +# The connection type for ReviewRequest. +type ReviewRequestConnection { + # A list of edges. + edges: [ReviewRequestEdge] + + # A list of nodes. + nodes: [ReviewRequest] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type ReviewRequestEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: ReviewRequest +} + +# Represents an 'review_request_removed' event on a given pull request. +type ReviewRequestRemovedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # Identifies the reviewer whose review request was removed. + requestedReviewer: RequestedReviewer +} + +# Represents an 'review_requested' event on a given pull request. +type ReviewRequestedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # PullRequest referenced by event. + pullRequest: PullRequest! + + # Identifies the reviewer whose review was requested. + requestedReviewer: RequestedReviewer +} + +# The results of a search. +union SearchResultItem = Issue | MarketplaceListing | Organization | PullRequest | Repository | User + +# A list of results that matched against a search query. +type SearchResultItemConnection { + # The number of pieces of code that matched the search query. + codeCount: Int! + + # A list of edges. + edges: [SearchResultItemEdge] + + # The number of issues that matched the search query. + issueCount: Int! + + # A list of nodes. + nodes: [SearchResultItem] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # The number of repositories that matched the search query. + repositoryCount: Int! + + # The number of users that matched the search query. + userCount: Int! + + # The number of wiki pages that matched the search query. + wikiCount: Int! +} + +# An edge in a connection. +type SearchResultItemEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: SearchResultItem + + # Text matches on the result found. + textMatches: [TextMatch] +} + +# Represents the individual results of a search. +enum SearchType { + # Returns results matching issues in repositories. + ISSUE + + # Returns results matching repositories. + REPOSITORY + + # Returns results matching users and organizations on GitHub. + USER +} + +# Represents an S/MIME signature on a Commit or Tag. +type SmimeSignature implements GitSignature { + # Email used to sign this object. + email: String! + + # True if the signature is valid and verified by GitHub. + isValid: Boolean! + + # Payload for GPG signing object. Raw ODB object without the signature header. + payload: String! + + # ASCII-armored signature header from object. + signature: String! + + # GitHub user corresponding to the email signing this commit. + signer: User + + # The state of this signature. `VALID` if signature is valid and verified by + # GitHub, otherwise represents reason why signature is considered invalid. + state: GitSignatureState! + + # True if the signature was made with GitHub's signing key. + wasSignedByGitHub: Boolean! +} + +# Ways in which star connections can be ordered. +input StarOrder { + # The direction in which to order nodes. + direction: OrderDirection! + + # The field in which to order nodes by. + field: StarOrderField! +} + +# Properties by which star connections can be ordered. +enum StarOrderField { + # Allows ordering a list of stars by when they were created. + STARRED_AT +} + +# The connection type for User. +type StargazerConnection { + # A list of edges. + edges: [StargazerEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a user that's starred a repository. +type StargazerEdge { + # A cursor for use in pagination. + cursor: String! + node: User! + + # Identifies when the item was starred. + starredAt: DateTime! +} + +# Things that can be starred. +interface Starrable { + id: ID! + + # A list of users who have starred this starrable. + stargazers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: StarOrder + ): StargazerConnection! + + # Returns a boolean indicating whether the viewing user has starred this starrable. + viewerHasStarred: Boolean! +} + +# The connection type for Repository. +type StarredRepositoryConnection { + # A list of edges. + edges: [StarredRepositoryEdge] + + # A list of nodes. + nodes: [Repository] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a starred repository. +type StarredRepositoryEdge { + # A cursor for use in pagination. + cursor: String! + node: Repository! + + # Identifies when the item was starred. + starredAt: DateTime! +} + +# Represents a commit status. +type Status implements Node { + # The commit this status is attached to. + commit: Commit + + # Looks up an individual status context by context name. + context( + # The context name. + name: String! + ): StatusContext + + # The individual status contexts for this commit. + contexts: [StatusContext!]! + id: ID! + + # The combined commit status. + state: StatusState! +} + +# Represents an individual commit status context +type StatusContext implements Node { + # This commit this status context is attached to. + commit: Commit + + # The name of this status context. + context: String! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The actor who created this status context. + creator: Actor + + # The description for this status context. + description: String + id: ID! + + # The state of this status context. + state: StatusState! + + # The URL for this status context. + targetUrl: URI +} + +# The possible commit status states. +enum StatusState { + # Status is errored. + ERROR + + # Status is expected. + EXPECTED + + # Status is failing. + FAILURE + + # Status is pending. + PENDING + + # Status is successful. + SUCCESS +} + +# Autogenerated input type of SubmitPullRequestReview +input SubmitPullRequestReviewInput { + # The text field to set on the Pull Request Review. + body: String + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The event to send to the Pull Request Review. + event: PullRequestReviewEvent! + + # The Pull Request Review ID to submit. + pullRequestReviewId: ID! +} + +# Autogenerated return type of SubmitPullRequestReview +type SubmitPullRequestReviewPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The submitted pull request review. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequestReview` will change from `PullRequestReview!` to `PullRequestReview`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequestReview: PullRequestReview! +} + +# Entities that can be subscribed to for web and email notifications. +interface Subscribable { + id: ID! + + # Check if the viewer is able to change their subscription status for the repository. + viewerCanSubscribe: Boolean! + + # Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. + viewerSubscription: SubscriptionState +} + +# Represents a 'subscribed' event on a given `Subscribable`. +type SubscribedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Object referenced by event. + subscribable: Subscribable! +} + +# The possible states of a subscription. +enum SubscriptionState { + # The User is never notified. + IGNORED + + # The User is notified of all conversations. + SUBSCRIBED + + # The User is only notified when particpating or @mentioned. + UNSUBSCRIBED +} + +# A suggestion to review a pull request based on a user's commit history and review comments. +type SuggestedReviewer { + # Is this suggestion based on past commits? + isAuthor: Boolean! + + # Is this suggestion based on past review comments? + isCommenter: Boolean! + + # Identifies the user suggested to review the pull request. + reviewer: User! +} + +# Represents a Git tag. +type Tag implements GitObject & Node { + # An abbreviated version of the Git object ID + abbreviatedOid: String! + + # The HTTP path for this Git object + commitResourcePath: URI! + + # The HTTP URL for this Git object + commitUrl: URI! + id: ID! + + # The Git tag message. + message: String + + # The Git tag name. + name: String! + + # The Git object ID + oid: GitObjectID! + + # The Repository the Git object belongs to + repository: Repository! + + # Details about the tag author. + tagger: GitActor + + # The Git object the tag points to. + target: GitObject! +} + +# A team of users in an organization. +type Team implements Node & Subscribable { + # A list of teams that are ancestors of this team. + ancestors( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): TeamConnection! + + # A URL pointing to the team's avatar. + avatarUrl( + # The size in pixels of the resulting square image. + size: Int = 400 + ): URI + + # List of child teams belonging to this team + childTeams( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Whether to list immediate child teams or all descendant child teams. + immediateOnly: Boolean = true + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: TeamOrder + + # User logins to filter by + userLogins: [String!] + ): TeamConnection! + + # The slug corresponding to the organization and team. + combinedSlug: String! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # The description of the team. + description: String + + # The HTTP path for editing this team + editTeamResourcePath: URI! + + # The HTTP URL for editing this team + editTeamUrl: URI! + id: ID! + + # A list of pending invitations for users to this team + invitations( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): OrganizationInvitationConnection + + # A list of users who are members of this team. + members( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Filter by membership type + membership: TeamMembershipType = ALL + + # Order for the connection. + orderBy: TeamMemberOrder + + # The search string to look for. + query: String + + # Filter by team member role + role: TeamMemberRole + ): TeamMemberConnection! + + # The HTTP path for the team' members + membersResourcePath: URI! + + # The HTTP URL for the team' members + membersUrl: URI! + + # The name of the team. + name: String! + + # The HTTP path creating a new team + newTeamResourcePath: URI! + + # The HTTP URL creating a new team + newTeamUrl: URI! + + # The organization that owns this team. + organization: Organization! + + # The parent team of the team. + parentTeam: Team + + # The level of privacy the team has. + privacy: TeamPrivacy! + + # A list of repositories this team has access to. + repositories( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for the connection. + orderBy: TeamRepositoryOrder + + # The search string to look for. + query: String + ): TeamRepositoryConnection! + + # The HTTP path for this team's repositories + repositoriesResourcePath: URI! + + # The HTTP URL for this team's repositories + repositoriesUrl: URI! + + # The HTTP path for this team + resourcePath: URI! + + # The slug corresponding to the team. + slug: String! + + # The HTTP path for this team's teams + teamsResourcePath: URI! + + # The HTTP URL for this team's teams + teamsUrl: URI! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this team + url: URI! + + # Team is adminable by the viewer. + viewerCanAdminister: Boolean! + + # Check if the viewer is able to change their subscription status for the repository. + viewerCanSubscribe: Boolean! + + # Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. + viewerSubscription: SubscriptionState +} + +# The connection type for Team. +type TeamConnection { + # A list of edges. + edges: [TeamEdge] + + # A list of nodes. + nodes: [Team] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type TeamEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Team +} + +# The connection type for User. +type TeamMemberConnection { + # A list of edges. + edges: [TeamMemberEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a user who is a member of a team. +type TeamMemberEdge { + # A cursor for use in pagination. + cursor: String! + + # The HTTP path to the organization's member access page. + memberAccessResourcePath: URI! + + # The HTTP URL to the organization's member access page. + memberAccessUrl: URI! + node: User! + + # The role the member has on the team. + role: TeamMemberRole! +} + +# Ordering options for team member connections +input TeamMemberOrder { + # The ordering direction. + direction: OrderDirection! + + # The field to order team members by. + field: TeamMemberOrderField! +} + +# Properties by which team member connections can be ordered. +enum TeamMemberOrderField { + # Order team members by creation time + CREATED_AT + + # Order team members by login + LOGIN +} + +# The possible team member roles; either 'maintainer' or 'member'. +enum TeamMemberRole { + # A team maintainer has permission to add and remove team members. + MAINTAINER + + # A team member has no administrative permissions on the team. + MEMBER +} + +# Defines which types of team members are included in the returned list. Can be one of IMMEDIATE, CHILD_TEAM or ALL. +enum TeamMembershipType { + # Includes immediate and child team members for the team. + ALL + + # Includes only child team members for the team. + CHILD_TEAM + + # Includes only immediate members of the team. + IMMEDIATE +} + +# Ways in which team connections can be ordered. +input TeamOrder { + # The direction in which to order nodes. + direction: OrderDirection! + + # The field in which to order nodes by. + field: TeamOrderField! +} + +# Properties by which team connections can be ordered. +enum TeamOrderField { + # Allows ordering a list of teams by name. + NAME +} + +# The possible team privacy values. +enum TeamPrivacy { + # A secret team can only be seen by its members. + SECRET + + # A visible team can be seen and @mentioned by every member of the organization. + VISIBLE +} + +# The connection type for Repository. +type TeamRepositoryConnection { + # A list of edges. + edges: [TeamRepositoryEdge] + + # A list of nodes. + nodes: [Repository] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# Represents a team repository. +type TeamRepositoryEdge { + # A cursor for use in pagination. + cursor: String! + node: Repository! + + # The permission level the team has on the repository + permission: RepositoryPermission! +} + +# Ordering options for team repository connections +input TeamRepositoryOrder { + # The ordering direction. + direction: OrderDirection! + + # The field to order repositories by. + field: TeamRepositoryOrderField! +} + +# Properties by which team repository connections can be ordered. +enum TeamRepositoryOrderField { + # Order repositories by creation time + CREATED_AT + + # Order repositories by name + NAME + + # Order repositories by permission + PERMISSION + + # Order repositories by push time + PUSHED_AT + + # Order repositories by number of stargazers + STARGAZERS + + # Order repositories by update time + UPDATED_AT +} + +# The role of a user on a team. +enum TeamRole { + # User has admin rights on the team. + ADMIN + + # User is a member of the team. + MEMBER +} + +# A text match within a search result. +type TextMatch { + # The specific text fragment within the property matched on. + fragment: String! + + # Highlights within the matched fragment. + highlights: [TextMatchHighlight!]! + + # The property matched on. + property: String! +} + +# Represents a single highlight in a search result match. +type TextMatchHighlight { + # The indice in the fragment where the matched text begins. + beginIndice: Int! + + # The indice in the fragment where the matched text ends. + endIndice: Int! + + # The text matched. + text: String! +} + +# A topic aggregates entities that are related to a subject. +type Topic implements Node { + id: ID! + + # The topic's name. + name: String! + + # A list of related topics, including aliases of this topic, sorted with the most relevant + # first. + relatedTopics: [Topic!]! +} + +# The connection type for Topic. +type TopicConnection { + # A list of edges. + edges: [TopicEdge] + + # A list of nodes. + nodes: [Topic] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type TopicEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: Topic +} + +# Reason that the suggested topic is declined. +enum TopicSuggestionDeclineReason { + # The suggested topic is not relevant to the repository. + NOT_RELEVANT + + # The viewer does not like the suggested topic. + PERSONAL_PREFERENCE + + # The suggested topic is too general for the repository. + TOO_GENERAL + + # The suggested topic is too specific for the repository (e.g. #ruby-on-rails-version-4-2-1). + TOO_SPECIFIC +} + +# Represents a Git tree. +type Tree implements GitObject & Node { + # An abbreviated version of the Git object ID + abbreviatedOid: String! + + # The HTTP path for this Git object + commitResourcePath: URI! + + # The HTTP URL for this Git object + commitUrl: URI! + + # A list of tree entries. + entries: [TreeEntry!] + id: ID! + + # The Git object ID + oid: GitObjectID! + + # The Repository the Git object belongs to + repository: Repository! +} + +# Represents a Git tree entry. +type TreeEntry { + # Entry file mode. + mode: Int! + + # Entry file name. + name: String! + + # Entry file object. + object: GitObject + + # Entry file Git object ID. + oid: GitObjectID! + + # The Repository the tree entry belongs to + repository: Repository! + + # Entry file type. + type: String! +} + +# An RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI string. +scalar URI + +# Represents an 'unassigned' event on any assignable object. +type UnassignedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the assignable associated with the event. + assignable: Assignable! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the subject (user) who was unassigned. + user: User +} + +# Represents a type that can be retrieved by a URL. +interface UniformResourceLocatable { + # The HTML path to this resource. + resourcePath: URI! + + # The URL to this resource. + url: URI! +} + +# Represents an unknown signature on a Commit or Tag. +type UnknownSignature implements GitSignature { + # Email used to sign this object. + email: String! + + # True if the signature is valid and verified by GitHub. + isValid: Boolean! + + # Payload for GPG signing object. Raw ODB object without the signature header. + payload: String! + + # ASCII-armored signature header from object. + signature: String! + + # GitHub user corresponding to the email signing this commit. + signer: User + + # The state of this signature. `VALID` if signature is valid and verified by + # GitHub, otherwise represents reason why signature is considered invalid. + state: GitSignatureState! + + # True if the signature was made with GitHub's signing key. + wasSignedByGitHub: Boolean! +} + +# Represents an 'unlabeled' event on a given issue or pull request. +type UnlabeledEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Identifies the label associated with the 'unlabeled' event. + label: Label! + + # Identifies the `Labelable` associated with the event. + labelable: Labelable! +} + +# Autogenerated input type of UnlockLockable +input UnlockLockableInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # ID of the issue or pull request to be unlocked. + lockableId: ID! +} + +# Autogenerated return type of UnlockLockable +type UnlockLockablePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The item that was unlocked. + unlockedRecord: Lockable +} + +# Represents an 'unlocked' event on a given issue or pull request. +type UnlockedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Object that was unlocked. + lockable: Lockable! +} + +# Autogenerated input type of UnmarkIssueAsDuplicate +input UnmarkIssueAsDuplicateInput { + # ID of the issue or pull request currently considered canonical/authoritative/original. + canonicalId: ID! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # ID of the issue or pull request currently marked as a duplicate. + duplicateId: ID! +} + +# Autogenerated return type of UnmarkIssueAsDuplicate +type UnmarkIssueAsDuplicatePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The issue or pull request that was marked as a duplicate. + duplicate: IssueOrPullRequest +} + +# Autogenerated input type of UnresolveReviewThread +input UnresolveReviewThreadInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ID of the thread to unresolve + threadId: ID! +} + +# Autogenerated return type of UnresolveReviewThread +type UnresolveReviewThreadPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The thread to resolve. + thread: PullRequestReviewThread +} + +# Represents an 'unsubscribed' event on a given `Subscribable`. +type UnsubscribedEvent implements Node { + # Identifies the actor who performed the event. + actor: Actor + + # Identifies the date and time when the object was created. + createdAt: DateTime! + id: ID! + + # Object referenced by event. + subscribable: Subscribable! +} + +# Entities that can be updated. +interface Updatable { + # Check if the current viewer can update this object. + viewerCanUpdate: Boolean! +} + +# Comments that can be updated. +interface UpdatableComment { + # Reasons why the current viewer can not update this comment. + viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! +} + +# Autogenerated input type of UpdateCheckRun +input UpdateCheckRunInput { + # Possible further actions the integrator can perform, which a user may trigger. + actions: [CheckRunAction!] + + # The node of the check. + checkRunId: ID! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The time that the check run finished. + completedAt: DateTime + + # The final conclusion of the check. + conclusion: CheckConclusionState + + # The URL of the integrator's site that has the full details of the check. + detailsUrl: URI + + # A reference for the run on the integrator's system. + externalId: String + + # The name of the check. + name: String + + # Descriptive details about the run. + output: CheckRunOutput + + # The node ID of the repository. + repositoryId: ID! + + # The time that the check run began. + startedAt: DateTime + + # The current status. + status: RequestableCheckStatusState +} + +# Autogenerated return type of UpdateCheckRun +type UpdateCheckRunPayload { + # The updated check run. + checkRun: CheckRun + + # A unique identifier for the client performing the mutation. + clientMutationId: String +} + +# Autogenerated input type of UpdateCheckSuitePreferences +input UpdateCheckSuitePreferencesInput { + # The check suite preferences to modify. + autoTriggerPreferences: [CheckSuiteAutoTriggerPreference!]! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the repository. + repositoryId: ID! +} + +# Autogenerated return type of UpdateCheckSuitePreferences +type UpdateCheckSuitePreferencesPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated repository. + repository: Repository +} + +# Autogenerated input type of UpdateIssueComment +input UpdateIssueCommentInput { + # The updated text of the comment. + body: String! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ID of the IssueComment to modify. + id: ID! +} + +# Autogenerated return type of UpdateIssueComment +type UpdateIssueCommentPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated comment. + issueComment: IssueComment +} + +# Autogenerated input type of UpdateIssue +input UpdateIssueInput { + # An array of Node IDs of users for this issue. + assigneeIds: [ID!] + + # The body for the issue description. + body: String + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The ID of the Issue to modify. + id: ID! + + # An array of Node IDs of labels for this issue. + labelIds: [ID!] + + # The Node ID of the milestone for this issue. + milestoneId: ID + + # An array of Node IDs for projects associated with this issue. + projectIds: [ID!] + + # The desired issue state. + state: IssueState + + # The title for the issue. + title: String +} + +# Autogenerated return type of UpdateIssue +type UpdateIssuePayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The issue. + issue: Issue +} + +# Autogenerated input type of UpdateProjectCard +input UpdateProjectCardInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # Whether or not the ProjectCard should be archived + isArchived: Boolean + + # The note of ProjectCard. + note: String + + # The ProjectCard ID to update. + projectCardId: ID! +} + +# Autogenerated return type of UpdateProjectCard +type UpdateProjectCardPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated ProjectCard. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `projectCard` will change from `ProjectCard!` to `ProjectCard`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + projectCard: ProjectCard! +} + +# Autogenerated input type of UpdateProjectColumn +input UpdateProjectColumnInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of project column. + name: String! + + # The ProjectColumn ID to update. + projectColumnId: ID! +} + +# Autogenerated return type of UpdateProjectColumn +type UpdateProjectColumnPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated project column. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `projectColumn` will change from `ProjectColumn!` to `ProjectColumn`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + projectColumn: ProjectColumn! +} + +# Autogenerated input type of UpdateProject +input UpdateProjectInput { + # The description of project. + body: String + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The name of project. + name: String + + # The Project ID to update. + projectId: ID! + + # Whether the project is public or not. + public: Boolean + + # Whether the project is open or closed. + state: ProjectState +} + +# Autogenerated return type of UpdateProject +type UpdateProjectPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated project. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `project` will change from `Project!` to `Project`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + project: Project! +} + +# Autogenerated input type of UpdatePullRequestReviewComment +input UpdatePullRequestReviewCommentInput { + # The text of the comment. + body: String! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the comment to modify. + pullRequestReviewCommentId: ID! +} + +# Autogenerated return type of UpdatePullRequestReviewComment +type UpdatePullRequestReviewCommentPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated comment. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequestReviewComment` will change from + # `PullRequestReviewComment!` to `PullRequestReviewComment`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequestReviewComment: PullRequestReviewComment! +} + +# Autogenerated input type of UpdatePullRequestReview +input UpdatePullRequestReviewInput { + # The contents of the pull request review body. + body: String! + + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the pull request review to modify. + pullRequestReviewId: ID! +} + +# Autogenerated return type of UpdatePullRequestReview +type UpdatePullRequestReviewPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The updated pull request review. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `pullRequestReview` will change from `PullRequestReview!` to `PullRequestReview`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + pullRequestReview: PullRequestReview! +} + +# Autogenerated input type of UpdateSubscription +input UpdateSubscriptionInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The new state of the subscription. + state: SubscriptionState! + + # The Node ID of the subscribable object to modify. + subscribableId: ID! +} + +# Autogenerated return type of UpdateSubscription +type UpdateSubscriptionPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The input subscribable entity. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `subscribable` will change from `Subscribable!` to `Subscribable`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + subscribable: Subscribable! +} + +# Autogenerated input type of UpdateTopics +input UpdateTopicsInput { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # The Node ID of the repository. + repositoryId: ID! + + # An array of topic names. + topicNames: [String!]! +} + +# Autogenerated return type of UpdateTopics +type UpdateTopicsPayload { + # A unique identifier for the client performing the mutation. + clientMutationId: String + + # Names of the provided topics that are not valid. + invalidTopicNames: [String!] + + # The updated repository. + # + # **Upcoming Change on 2019-01-01 UTC** + # **Description:** Type for `repository` will change from `Repository!` to `Repository`. + # **Reason:** In preparation for an upcoming change to the way we report + # mutation errors, non-nullable payload fields are becoming nullable. + repository: Repository! +} + +# A user is an individual's account on GitHub that owns repositories and can make new content. +type User implements Actor & Node & RegistryPackageOwner & RegistryPackageSearch & RepositoryOwner & UniformResourceLocatable { + # A URL pointing to the user's public avatar. + avatarUrl( + # The size of the resulting square image. + size: Int + ): URI! + + # The user's public profile bio. + bio: String + + # The user's public profile bio as HTML. + bioHTML: HTML! + + # A list of commit comments made by this user. + commitComments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): CommitCommentConnection! + + # The user's public profile company. + company: String + + # The user's public profile company as HTML. + companyHTML: HTML! + + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the primary key from the database. + databaseId: Int + + # The user's publicly visible profile email. + email: String! + + # A list of users the given user is followed by. + followers( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): FollowerConnection! + + # A list of users the given user is following. + following( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): FollowingConnection! + + # Find gist by repo name. + gist( + # The gist name to find. + name: String! + ): Gist + + # A list of gist comments made by this user. + gistComments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): GistCommentConnection! + + # A list of the Gists the user has created. + gists( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for gists returned from the connection + orderBy: GistOrder + + # Filters Gists according to privacy. + privacy: GistPrivacy + ): GistConnection! + id: ID! + + # Whether or not this user is a participant in the GitHub Security Bug Bounty. + isBountyHunter: Boolean! + + # Whether or not this user is a participant in the GitHub Campus Experts Program. + isCampusExpert: Boolean! + + # Whether or not this user is a GitHub Developer Program member. + isDeveloperProgramMember: Boolean! + + # Whether or not this user is a GitHub employee. + isEmployee: Boolean! + + # Whether or not the user has marked themselves as for hire. + isHireable: Boolean! + + # Whether or not this user is a site administrator. + isSiteAdmin: Boolean! + + # Whether or not this user is the viewing user. + isViewer: Boolean! + + # A list of issue comments made by this user. + issueComments( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): IssueCommentConnection! + + # A list of issues associated with this user. + issues( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Filtering options for issues returned from the connection. + filterBy: IssueFilters + + # Returns the first _n_ elements from the list. + first: Int + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for issues returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the issues by. + states: [IssueState!] + ): IssueConnection! + + # The user's public profile location. + location: String + + # The username used to login. + login: String! + + # The user's public profile name. + name: String + + # Find an organization by its login that the user belongs to. + organization( + # The login of the organization to find. + login: String! + ): Organization + + # A list of organizations the user belongs to. + organizations( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): OrganizationConnection! + + # A list of repositories this user has pinned to their profile + pinnedRepositories( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # A list of public keys associated with this user. + publicKeys( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + ): PublicKeyConnection! + + # A list of pull requests associated with this user. + pullRequests( + # Returns the elements in the list that come after the specified cursor. + after: String + + # The base ref name to filter the pull requests by. + baseRefName: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # The head ref name to filter the pull requests by. + headRefName: String + + # A list of label names to filter the pull requests by. + labels: [String!] + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for pull requests returned from the connection. + orderBy: IssueOrder + + # A list of states to filter the pull requests by. + states: [PullRequestState!] + ): PullRequestConnection! + + # A list of repositories that the user owns. + repositories( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they are forks of another repository + isFork: Boolean + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # A list of repositories that the user recently contributed to. + repositoriesContributedTo( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # If non-null, include only the specified types of contributions. The + # GitHub.com UI uses [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY] + contributionTypes: [RepositoryContributionType] + + # Returns the first _n_ elements from the list. + first: Int + + # If true, include user repositories + includeUserRepositories: Boolean + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # Find Repository. + repository( + # Name of Repository to find. + name: String! + ): Repository + + # The HTTP path for this user + resourcePath: URI! + + # Repositories the user has starred. + starredRepositories( + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # Returns the last _n_ elements from the list. + last: Int + + # Order for connection + orderBy: StarOrder + + # Filters starred repositories to only return repositories owned by the viewer. + ownedByViewer: Boolean + ): StarredRepositoryConnection! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! + + # The HTTP URL for this user + url: URI! + + # Whether or not the viewer is able to follow the user. + viewerCanFollow: Boolean! + + # Whether or not this user is followed by the viewer. + viewerIsFollowing: Boolean! + + # A list of repositories the given user is watching. + watching( + # Affiliation options for repositories returned from the connection + affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR, ORGANIZATION_MEMBER] + + # Returns the elements in the list that come after the specified cursor. + after: String + + # Returns the elements in the list that come before the specified cursor. + before: String + + # Returns the first _n_ elements from the list. + first: Int + + # If non-null, filters repositories according to whether they have been locked + isLocked: Boolean + + # Returns the last _n_ elements from the list. + last: Int + + # Ordering options for repositories returned from the connection + orderBy: RepositoryOrder + + # If non-null, filters repositories according to privacy + privacy: RepositoryPrivacy + ): RepositoryConnection! + + # A URL pointing to the user's public website/blog. + websiteUrl: URI +} + +# The connection type for User. +type UserConnection { + # A list of edges. + edges: [UserEdge] + + # A list of nodes. + nodes: [User] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edit on user content +type UserContentEdit implements Node { + # Identifies the date and time when the object was created. + createdAt: DateTime! + + # Identifies the date and time when the object was deleted. + deletedAt: DateTime + + # The actor who deleted this content + deletedBy: Actor + + # A summary of the changes for this edit + diff: String + + # When this content was edited + editedAt: DateTime! + + # The actor who edited this content + editor: Actor + id: ID! + + # Identifies the date and time when the object was last updated. + updatedAt: DateTime! +} + +# A list of edits to content. +type UserContentEditConnection { + # A list of edges. + edges: [UserContentEditEdge] + + # A list of nodes. + nodes: [UserContentEdit] + + # Information to aid in pagination. + pageInfo: PageInfo! + + # Identifies the total count of items in the connection. + totalCount: Int! +} + +# An edge in a connection. +type UserContentEditEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: UserContentEdit +} + +# An edge in a connection. +type UserEdge { + # A cursor for use in pagination. + cursor: String! + + # The item at the end of the edge. + node: User +} + +# A valid x509 certificate string +scalar X509Certificate + +schema { + query: Query + mutation: Mutation +} -- GitLab From f5104aca095d7bde8f013dfdbb305c8e7ef529cb Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Mon, 10 Sep 2018 19:24:13 -0400 Subject: [PATCH 04/11] queries: compile our queries --- ghostflow-github/Cargo.toml | 11 + ghostflow-github/src/graphql/query.graphql | 460 +++++++++++++++++++++ ghostflow-github/src/lib.rs | 18 + ghostflow-github/src/queries.rs | 83 ++++ 4 files changed, 572 insertions(+) create mode 100644 ghostflow-github/src/graphql/query.graphql create mode 100644 ghostflow-github/src/queries.rs diff --git a/ghostflow-github/Cargo.toml b/ghostflow-github/Cargo.toml index 2dbcb742..1d819727 100644 --- a/ghostflow-github/Cargo.toml +++ b/ghostflow-github/Cargo.toml @@ -11,3 +11,14 @@ repository = "https://gitlab.kitware.com/utils/rust-ghostflow" documentation = "https://docs.rs/ghostflow-github/~0.1" readme = "README.md" keywords = ["git", "workflow", "ghostflow", "github"] + +[dependencies] +chrono = { version = "~0.4", features = ["serde"] } +#graphql_client = "~0.5" +serde_derive = "^1.0" +serde_json = "^1.0" + +serde = "^1.0" + +[dependencies.graphql_client] +git = "https://github.com/tomhoule/graphql-client.git" diff --git a/ghostflow-github/src/graphql/query.graphql b/ghostflow-github/src/graphql/query.graphql new file mode 100644 index 00000000..33197d8e --- /dev/null +++ b/ghostflow-github/src/graphql/query.graphql @@ -0,0 +1,460 @@ +# Copyright 2016 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +fragment UserInfo on User { + name + login + # XXX(github): It seems that having the `user:email` scope in the + # application isn't enough. Some OAuth hoops may be necessary here. + # email +} + +# fragment BotActorInfo on Bot { +# login +# } + +# fragment OrganizationActorInfo on Organization { +# name +# login +# email +# } + +# fragment UserActorInfo on User { +# name +# login +# email +# } + +fragment RepoInfo on Repository { + owner { + __typename + login + } + name + sshUrl + parent { + owner { + __typename + login + } + name + #...RepoInfo + } +} + +fragment IssueInfo on Issue { + repository { + ...RepoInfo + } + url + description: body + # Yes, we only care about the first 100 labels on an issue. + labels(first: 100) { + labels: nodes { + __typename + name + } + } + milestone { + title + } + # We only "care" about the first assignee, but get extras in case we get + # back `null` nodes. + assignees(first: 5) { + assignees: nodes { + __typename + login + } + } +} + +fragment PullRequestInfo on PullRequest { + sourceRepo: headRepository { + ...RepoInfo + } + sourceBranch: headRefName + targetRepo: repository { + ...RepoInfo + } + targetBranch: baseRefName + url + title + description: body + headRefOid + author { + __typename + # XXX(graphql-client): Interface/fragement references aren't quite + # right. + # https://github.com/tomhoule/graphql-client/issues/113 + ... on Bot { + login + } + ... on Organization { + name + login + email + } + ... on User { + name + login + email + } + # ...BotActorInfo + # ...OrganizationActorInfo + # ...UserActorInfo + } +} + +fragment IssueCommentInfo on IssueComment { + id + author { + __typename + # XXX(graphql-client): Interface/fragement references aren't quite + # right. + # https://github.com/tomhoule/graphql-client/issues/113 + ... on Bot { + login + } + ... on Organization { + name + login + email + } + ... on User { + name + login + email + } + # ...BotActorInfo + # ...OrganizationActorInfo + # ...UserActorInfo + } + createdAt + content: body +} + +fragment PullRequestReviewInfo on PullRequestReview { + id + author { + __typename + # XXX(graphql-client): Interface/fragement references aren't quite + # right. + # https://github.com/tomhoule/graphql-client/issues/113 + ... on Bot { + login + } + ... on Organization { + name + login + email + } + ... on User { + name + login + email + } + # ...BotActorInfo + # ...OrganizationActorInfo + # ...UserActorInfo + } + createdAt + content: body +} + +fragment PullRequestReviewCommentInfo on PullRequestReviewComment { + id + author { + __typename + # XXX(graphql-client): Interface/fragement references aren't quite + # right. + # https://github.com/tomhoule/graphql-client/issues/113 + ... on Bot { + login + } + ... on Organization { + name + login + email + } + ... on User { + name + login + email + } + # ...BotActorInfo + # ...OrganizationActorInfo + # ...UserActorInfo + } + createdAt + content: body +} + +query CurrentUser { + viewer { + ...UserInfo + } +} + +query Members($owner: String!, $name: String!, $cursor: String) { + repository(owner: $owner, name: $name) { + collaborators(first: 100, after: $cursor, affiliation: ALL) { + members: edges { + user: node { + ...UserInfo + } + permission + } + pageInfo { + endCursor + hasNextPage + } + } + } +} + +query User($name: String!) { + user(login: $name) { + ...UserInfo + } +} + +query Commit($owner: String!, $name: String!, $commit: GitObjectID!) { + repository(owner: $owner, name: $name) { + object(oid: $commit) { + __typename + repository { + ...RepoInfo + } + oid + } + } +} + +query Issue($owner: String!, $name: String!, $issue: Int!) { + repository(owner: $owner, name: $name) { + issue(number: $issue) { + ...IssueInfo + } + } +} + +query PullRequest($owner: String!, $name: String!, $pull: Int!) { + repository(owner: $owner, name: $name) { + pullRequest(number: $pull) { + ...PullRequestInfo + } + } +} + +query Repository($owner: String!, $name: String!) { + repository(owner: $owner, name: $name) { + ...RepoInfo + } +} + +query IssueComments($owner: String!, $name: String!, $id: Int!, $cursor: String) { + repository(owner: $owner, name: $name) { + issue(number: $id) { + timeline(first: 100, after: $cursor) { + items: nodes { + __typename + ... on IssueComment { + ...IssueCommentInfo + } + } + pageInfo { + endCursor + hasNextPage + } + } + } + } +} + +query IssueID($owner: String!, $name: String!, $issue: Int!) { + repository(owner: $owner, name: $name) { + issue(number: $issue) { + id + } + } +} + +mutation PostComment($input: AddCommentInput!) { + addComment(input: $input) { + # XXX(graphql): We need to request *something* back. + clientMutationId + } +} + +query PullRequestComments($owner: String!, $name: String!, $pull: Int!, $cursor: String) { + repository(owner: $owner, name: $name) { + pullRequest(number: $pull) { + timeline(first: 100, after: $cursor) { + items: nodes { + __typename + # TODO: Replace this with `Push` if/when that happens. + ... on Commit { + id + pushedDate + committedDate, + author { + user { + ...UserInfo + } + name + email + } + message + } + ... on IssueComment { + ...IssueCommentInfo + } + ... on PullRequestReview { + ...PullRequestReviewInfo + } + ... on PullRequestReviewComment { + ...PullRequestReviewCommentInfo + } + # TODO: Get commit comments + } + pageInfo { + endCursor + hasNextPage + } + } + } + } +} + +query PullRequestID($owner: String!, $name: String!, $pull: Int!) { + repository(owner: $owner, name: $name) { + pullRequest(number: $pull) { + id + } + } +} + +query CommitID($owner: String!, $name: String!, $commit: GitObjectID!) { + repository(owner: $owner, name: $name) { + object(oid: $commit) { + __typename + ... on Commit { + id + } + } + } +} + +query CommitStatuses($owner: String!, $name: String!, $commit: GitObjectID!, $appId: Int!) { + repository(owner: $owner, name: $name) { + object(oid: $commit) { + __typename + ... on Commit { + checkSuites(first: 1, filterBy: { appId: $appId }) { + checkSuite: nodes { + __typename + branch { + name + } + + # XXX(ghostflow): Not caring about paging this; if + # ghostflow has 100+ latest check runs, it's not a + # supported configuration. + checkRuns(first: 100, filterBy: { appId: $appId, status: COMPLETED, checkType: LATEST }) { + checkRuns: nodes { + conclusion + name + summary + } + } + } + } + } + } + } +} + +query RepositoryID($owner: String!, $name: String!) { + repository(owner: $owner, name: $name) { + id + } +} + +mutation PostCheckRun($input: CreateCheckRunInput!) { + createCheckRun(input: $input) { + # XXX(graphql): We need to request *something* back. + clientMutationId + } +} + +query PullRequestReactions($owner: String!, $name: String!, $pull: Int!, $cursor: String) { + repository(owner: $owner, name: $name) { + pullRequest(number: $pull) { + reactions(first: 100, after: $cursor) { + reactions: nodes { + __typename + content + user { + ...UserInfo + } + } + pageInfo { + endCursor + hasNextPage + } + } + } + } +} + +query PullRequestCommentReactions($id: ID!, $cursor: String) { + node(id: $id) { + __typename + ... on IssueComment { + reactions(first: 100, after: $cursor) { + reactions: nodes { + __typename + content + user { + ...UserInfo + } + } + pageInfo { + endCursor + hasNextPage + } + } + } + } +} + +mutation ReactToPullRequestComment($input: AddReactionInput!) { + addReaction(input: $input) { + # XXX(graphql): We need to request *something* back. + clientMutationId + } +} + +# query IssuesClosedByPullRequest { +# # TODO: implement +# } + +query LabelID($owner: String!, $name: String!, $label: String!) { + repository(owner: $owner, name: $name) { + label(name: $label) { + id + } + } +} + +mutation AddIssueLabels($input: AddLabelsToLabelableInput!) { + addLabelsToLabelable(input: $input) { + # XXX(graphql): We need to request *something* back. + clientMutationId + } +} diff --git a/ghostflow-github/src/lib.rs b/ghostflow-github/src/lib.rs index e15a4f06..548089bd 100644 --- a/ghostflow-github/src/lib.rs +++ b/ghostflow-github/src/lib.rs @@ -5,3 +5,21 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. + +#[macro_use] +extern crate graphql_client; + +#[macro_use] +extern crate serde_derive; + +mod crates { + pub extern crate chrono; + pub extern crate graphql_client; + pub extern crate serde_json; + + pub extern crate serde; +} + +// Required to be in the root for `graphql-client`. +use crates::serde; +pub(crate) mod queries; diff --git a/ghostflow-github/src/queries.rs b/ghostflow-github/src/queries.rs new file mode 100644 index 00000000..df810867 --- /dev/null +++ b/ghostflow-github/src/queries.rs @@ -0,0 +1,83 @@ +// Copyright 2016 Kitware, Inc. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// We are ignoring warnings about `GraphQLQuery` not being used in this module. +#![allow(unused_imports)] + +use crates::chrono::{self, Utc}; + +type DateTime = chrono::DateTime<Utc>; +type GitObjectID = String; +type GitSSHRemote = String; +type URI = String; + +macro_rules! gql_query { + ($name:ident) => { + #[derive(GraphQLQuery)] + #[graphql( + schema_path = "src/graphql/schema.graphql", + query_path = "src/graphql/query.graphql", + deprecated = "warn", + response_derives = "Debug, Clone", + )] + pub struct $name; + }; +} + +gql_query!(CurrentUser); +gql_query!(Members); +gql_query!(User); +gql_query!(Commit); +gql_query!(Issue); +gql_query!(PullRequest); +gql_query!(Repository); +gql_query!(IssueComments); +gql_query!(IssueID); +gql_query!(PullRequestComments); +gql_query!(PullRequestID); +gql_query!(CommitID); +gql_query!(CommitStatuses); +gql_query!(RepositoryID); +gql_query!(PullRequestReactions); +gql_query!(PullRequestCommentReactions); +// gql_query!(IssuesClosedByPullRequest); +gql_query!(LabelID); + +gql_query!(PostComment); +gql_query!(PostCheckRun); +gql_query!(ReactToPullRequestComment); +gql_query!(AddIssueLabels); + +pub(crate) trait RepoInfo { + fn name(&self) -> String; + fn ssh_url(&self) -> &str; + fn parent(&self) -> Option<(&str, &str)>; +} + +macro_rules! impl_repo_info { + ($type:path) => { + impl RepoInfo for $type { + fn name(&self) -> String { + format!("{}/{}", self.owner.login, self.name) + } + + fn ssh_url(&self) -> &str { + &self.ssh_url + } + + fn parent(&self) -> Option<(&str, &str)> { + self.parent.as_ref().map(|parent| (parent.owner.login.as_ref(), parent.name.as_ref())) + } + } + }; +} + +impl_repo_info!(commit::RepoInfo); +impl_repo_info!(issue::RepoInfo); +impl_repo_info!(pull_request::RepoInfo); +impl_repo_info!(repository::RepoInfo); -- GitLab From d178c8ea73522f3cf32c02c09be960f18bb5994e Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Thu, 13 Sep 2018 17:33:20 -0400 Subject: [PATCH 05/11] error: add an Error type --- ghostflow-github/Cargo.toml | 1 + ghostflow-github/src/error.rs | 71 +++++++++++++++++++++++++++++++++++ ghostflow-github/src/lib.rs | 6 +++ 3 files changed, 78 insertions(+) create mode 100644 ghostflow-github/src/error.rs diff --git a/ghostflow-github/Cargo.toml b/ghostflow-github/Cargo.toml index 1d819727..36db829b 100644 --- a/ghostflow-github/Cargo.toml +++ b/ghostflow-github/Cargo.toml @@ -18,6 +18,7 @@ chrono = { version = "~0.4", features = ["serde"] } serde_derive = "^1.0" serde_json = "^1.0" +failure = "~0.1" serde = "^1.0" [dependencies.graphql_client] diff --git a/ghostflow-github/src/error.rs b/ghostflow-github/src/error.rs new file mode 100644 index 00000000..4f994628 --- /dev/null +++ b/ghostflow-github/src/error.rs @@ -0,0 +1,71 @@ +// Copyright 2016 Kitware, Inc. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crates::failure::{Backtrace, Context, Fail}; + +use std::fmt::{self, Display}; +use std::result::Result as StdResult; + +#[derive(Debug, Clone, PartialEq, Fail)] +pub(crate) enum ErrorKind { + #[fail(display = "url parse error")] + UrlParse, + /// Failed to send a request. + #[fail(display = "failed to send a request to github")] + SendRequest, + /// Failed to deserialize a Github result into a structure. + #[fail(display = "deserialization error")] + Deserialize, + /// GitHub gave us back a failure. + #[fail(display = "GitHub error: {}", _0)] + Github(String), + /// GitHub gave us back an empty result with no error messages. + #[fail(display = "no response from GitHub")] + NoResponse, +} + +/// An error within the GitHub ghostflow support. +#[derive(Debug)] +pub struct Error { + inner: Context<ErrorKind>, +} + +impl Fail for Error { + fn cause(&self) -> Option<&Fail> { + self.inner.cause() + } + + fn backtrace(&self) -> Option<&Backtrace> { + self.inner.backtrace() + } +} + +impl Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + Display::fmt(&self.inner, f) + } +} + +impl From<ErrorKind> for Error { + fn from(kind: ErrorKind) -> Self { + Self { + inner: Context::new(kind), + } + } +} + +impl From<Context<ErrorKind>> for Error { + fn from(inner: Context<ErrorKind>) -> Self { + Self { + inner: inner, + } + } +} + +/// A convenient type alias. +pub type Result<T> = StdResult<T, Error>; diff --git a/ghostflow-github/src/lib.rs b/ghostflow-github/src/lib.rs index 548089bd..6bab4f73 100644 --- a/ghostflow-github/src/lib.rs +++ b/ghostflow-github/src/lib.rs @@ -6,6 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[macro_use] +extern crate failure; + #[macro_use] extern crate graphql_client; @@ -17,9 +20,12 @@ mod crates { pub extern crate graphql_client; pub extern crate serde_json; + pub extern crate failure; pub extern crate serde; } +pub mod error; + // Required to be in the root for `graphql-client`. use crates::serde; pub(crate) mod queries; -- GitLab From 4d47ddd433faf6ff5ac213836bb6fc06f69d5c4d Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Thu, 13 Sep 2018 17:35:26 -0400 Subject: [PATCH 06/11] client: add a basic GitHub client structure --- ghostflow-github/Cargo.toml | 7 + ghostflow-github/src/client.rs | 239 +++++++++++++++++++++++++++++++++ ghostflow-github/src/error.rs | 6 + ghostflow-github/src/lib.rs | 10 ++ 4 files changed, 262 insertions(+) create mode 100644 ghostflow-github/src/client.rs diff --git a/ghostflow-github/Cargo.toml b/ghostflow-github/Cargo.toml index 36db829b..d3cbe86d 100644 --- a/ghostflow-github/Cargo.toml +++ b/ghostflow-github/Cargo.toml @@ -15,8 +15,15 @@ keywords = ["git", "workflow", "ghostflow", "github"] [dependencies] chrono = { version = "~0.4", features = ["serde"] } #graphql_client = "~0.5" +hyper = { version = "~0.11.9", default-features = false } +jsonwebtoken = "^5.0" +log = "~0.4" +pem = "~0.5" +reqwest = "~0.8" serde_derive = "^1.0" serde_json = "^1.0" +#ttl_cache = "~0.5" +ttl_cache = { git = "https://github.com/mathstuf/rust-ttl_cache.git", branch = "add-ttl-value" } failure = "~0.1" serde = "^1.0" diff --git a/ghostflow-github/src/client.rs b/ghostflow-github/src/client.rs new file mode 100644 index 00000000..887b2df6 --- /dev/null +++ b/ghostflow-github/src/client.rs @@ -0,0 +1,239 @@ +// Copyright 2016 Kitware, Inc. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crates::chrono::{DateTime, Duration, Utc}; +use crates::failure::{ResultExt, SyncFailure}; +use crates::hyper::header::{Accept, Authorization, UserAgent, qitem}; +use crates::jsonwebtoken::{self, Algorithm, Header}; +use crates::pem; +use crates::reqwest::{Client, Url}; +use crates::ttl_cache::TtlValue; + +use std::sync::RwLock; +use std::time::{self, Instant}; + +use error::*; + +const LOCK_POISONED: &str = "token lock poisoned"; +// XXX(const_fn): Create the duration here. +const TOKEN_SLACK_PERIOD: u64 = 5 * 60; + +/// The return type for installation token generation. +#[derive(Deserialize)] +struct InstallationToken { + token: String, + expires_at: DateTime<Utc>, +} + +/// A client for communicating with a Github instance. +pub struct Github { + /// The client used to communicate with Github. + client: Client, + /// The client ID. + /// + /// This is used to indicate the client associated with some endpoints. + client_id: String, + /// The base endpoint for REST queries. + app_endpoint: Url, + /// The endpoint for GraphQL queries. + gql_endpoint: Url, + + /// The application ID. + app_id: i64, + /// The application private key. + private_key: Vec<u8>, + + /// The installation ID. + installation_id: String, + /// The token for querying GraphQL endpoints. + token: RwLock<TtlValue<String>>, +} + +#[derive(Debug, Serialize)] +struct Claims { + iat: i64, + exp: i64, + iss: i64, +} + +impl Github { + /// Create a new Github client. + /// + /// The `host` parameter is the API endpoint. For example `github.com` uses `api.github.com`. + /// + /// The `app_id` and `private_key` are provided when [registering the application][new-app]. + /// The `installation_id` is an ID associated with a given installation of the application. Its + /// value is present in webhooks, but does not seem to be available generically. + /// + /// [new-app]: https://developer.github.com/apps/building-your-first-github-app/#register-a-new-app-with-github + pub fn new<H, C, P, I>(host: H, client_id: C, app_id: i64, private_key: P, installation_id: I) -> Result<Self> + where H: AsRef<str>, + C: ToString, + P: AsRef<[u8]>, + I: ToString, + { + let app_endpoint = Url::parse(&format!("https://{}", host.as_ref())) + .context(ErrorKind::UrlParse)?; + let gql_endpoint = Url::parse(&format!("https://{}/graphql", host.as_ref())) + .context(ErrorKind::UrlParse)?; + + let private_key = private_key.as_ref(); + // Try to detect a PEM-encoded key (which is what GitHub provides). + let private_key = if private_key.starts_with(b"-----BEGIN RSA PRIVATE KEY-----") { + pem::parse(private_key) + .map_err(SyncFailure::new) + .context(ErrorKind::Pem)? + .contents + } else { + private_key.into() + }; + + let api = Github { + client: Client::new(), + client_id: client_id.to_string(), + app_endpoint: app_endpoint, + gql_endpoint: gql_endpoint, + app_id: app_id, + installation_id: installation_id.to_string(), + private_key: private_key, + // Use a dummy token which is invalid right now. It will automatically be + // refreshed when necessary. + token: RwLock::new(TtlValue::new(String::new(), Instant::now())), + }; + + // Update the token. + api.refresh_installation_token()?; + + Ok(api) + } + + pub(crate) fn client_id(&self) -> &str { + &self.client_id + } + + pub(crate) fn app_id(&self) -> i64 { + self.app_id + } + + fn jwt(&self) -> Result<String> { + let header = Header::new(Algorithm::RS256); + let now = Utc::now(); + let expiration = now + Duration::minutes(10); + let claims = Claims { + iat: now.timestamp(), + exp: expiration.timestamp(), + iss: self.app_id, + }; + Ok(jsonwebtoken::encode( + &header, + &claims, + &self.private_key, + ) + .context(ErrorKind::Jwt)?) + } + + /// Accept headers for the application. + /// + /// The application endpoint is a v3 API. + fn app_accept_headers(&self) -> Accept { + Accept(vec![ + // GitHub v3 API + qitem("application/vnd.github.v3+json".parse() + .expect("the GitHub v3 API MIME type should be valid")), + // GitHub App installations + qitem("application/vnd.github.machine-man-preview+json".parse() + .expect("the GitHub App installations MIME type should be valid")), + ]) + } + + /// The authorization header for JWT-guarded API endpoints. + fn jwt_auth_header(&self) -> Result<Authorization<String>> { + Ok(Authorization(format!("Bearer {}", self.jwt()?))) + } + + /// Fetch a token for our installation. + /// + /// GraphQL requires an installation token in order to access some endpoints. This allows us to + /// do things which only "bots" are allowed to do (such as submitting status runs for pull + /// requests). + fn new_installation_token(&self) -> Result<(String, Instant)> { + let mut rsp = self.client + .post(self.app_endpoint.join(&format!("app/installations/{}/access_tokens", self.installation_id)) + .context(ErrorKind::UrlParse)?) + .header(self.jwt_auth_header()?) + .header(self.app_accept_headers()) + .header(UserAgent::new("ghostflow-github")) + .send() + .context(ErrorKind::SendRequest)?; + if !rsp.status().is_success() { + let err = rsp.text() + .unwrap_or_else(|text_err| { + format!("failed to extract error body: {:?}", + text_err) + }); + Err(ErrorKind::Github(err))?; + } + + let rsp: InstallationToken = rsp + .json() + .context(ErrorKind::Deserialize)?; + // How log GitHub lets the token live for... + let now = Utc::now(); + let token_duration = rsp.expires_at.signed_duration_since(now) + .to_std() + .map_err(|_| { + let msg = format!( + "GitHub gave us an expiration time in the future: {} (it is now {})", + rsp.expires_at, + now, + ); + error!(target: "github", "{}", msg); + ErrorKind::Github(msg) + })?; + // ...but let's take some time off of it to give us some breathing room. + let token_duration = token_duration.checked_sub(time::Duration::from_secs(TOKEN_SLACK_PERIOD)) + // Though if that's more time than we have, let's use it while we can. + .unwrap_or(token_duration); + Ok((rsp.token, Instant::now() + token_duration)) + } + + /// Get the token for GraphQL queries. + /// + /// This token can expire, but if it has, it will be refreshed automatically. + fn token(&self) -> Result<String> { + // Check for a valid token. + { + let lock = self.token.read().expect(LOCK_POISONED); + if let Some(token) = lock.as_ref() { + return Ok(token.to_string()); + } + } + + // No valid token, let's try and get a new one. + self.refresh_installation_token() + } + + /// Refresh the installation token. + fn refresh_installation_token(&self) -> Result<String> { + // Grab an exclusive lock. + let mut lock = self.token.write().expect(LOCK_POISONED); + + // Check if the token is valid again. Multiple queries may have noticed an expired token + // while one request is fulfilling it. If the token is valid again, use it. + if let Some(token) = lock.as_ref() { + return Ok(token.to_string()); + } + + let (new_token, new_expiration) = self.new_installation_token()?; + // Update the token. The `as_ref_or_update` method cannot be used because + // `new_installation_token` returns a `Result`. + lock.update(new_token.clone(), new_expiration); + // Return the new token. + Ok(new_token) + } +} diff --git a/ghostflow-github/src/error.rs b/ghostflow-github/src/error.rs index 4f994628..991b4753 100644 --- a/ghostflow-github/src/error.rs +++ b/ghostflow-github/src/error.rs @@ -21,6 +21,12 @@ pub(crate) enum ErrorKind { /// Failed to deserialize a Github result into a structure. #[fail(display = "deserialization error")] Deserialize, + /// Failed to parse a PEM file. + #[fail(display = "failed to parse PEM")] + Pem, + /// Failed to create a JWT. + #[fail(display = "failed to create a JWT")] + Jwt, /// GitHub gave us back a failure. #[fail(display = "GitHub error: {}", _0)] Github(String), diff --git a/ghostflow-github/src/lib.rs b/ghostflow-github/src/lib.rs index 6bab4f73..b502357c 100644 --- a/ghostflow-github/src/lib.rs +++ b/ghostflow-github/src/lib.rs @@ -12,12 +12,20 @@ extern crate failure; #[macro_use] extern crate graphql_client; +#[macro_use] +extern crate log; + #[macro_use] extern crate serde_derive; mod crates { pub extern crate chrono; pub extern crate graphql_client; + pub extern crate hyper; + pub extern crate jsonwebtoken; + pub extern crate pem; + pub extern crate reqwest; + pub extern crate ttl_cache; pub extern crate serde_json; pub extern crate failure; @@ -29,3 +37,5 @@ pub mod error; // Required to be in the root for `graphql-client`. use crates::serde; pub(crate) mod queries; +mod client; +pub use client::Github; -- GitLab From aad59bd6452e31e4be981689cdb54792e7733a72 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Thu, 13 Sep 2018 17:37:22 -0400 Subject: [PATCH 07/11] client: add an API for handling a GraphQL query --- ghostflow-github/src/client.rs | 56 ++++++++++++++++++++++++++++++++++ ghostflow-github/src/error.rs | 16 ++++++++++ 2 files changed, 72 insertions(+) diff --git a/ghostflow-github/src/client.rs b/ghostflow-github/src/client.rs index 887b2df6..fa4678c3 100644 --- a/ghostflow-github/src/client.rs +++ b/ghostflow-github/src/client.rs @@ -8,10 +8,12 @@ use crates::chrono::{DateTime, Duration, Utc}; use crates::failure::{ResultExt, SyncFailure}; +use crates::graphql_client::{GraphQLQuery, QueryBody, Response}; use crates::hyper::header::{Accept, Authorization, UserAgent, qitem}; use crates::jsonwebtoken::{self, Algorithm, Header}; use crates::pem; use crates::reqwest::{Client, Url}; +use crates::serde::Deserialize; use crates::ttl_cache::TtlValue; use std::sync::RwLock; @@ -236,4 +238,58 @@ impl Github { // Return the new token. Ok(new_token) } + + /// The authorization header for GraphQL. + fn installation_auth_header(&self) -> Result<Authorization<String>> { + Ok(Authorization(format!("token {}", self.token()?))) + } + + /// Accept headers for GraphQL. + /// + /// We're using preview APIs and we need these to get access to them. + fn gql_accept_headers(&self) -> Accept { + Accept(vec![ + // Checks + qitem("application/vnd.github.antiope-preview+json".parse() + .expect("the checks MIME type should be valid")), + // Resolvable threads + qitem("application/vnd.github.cateye-preview+json".parse() + .expect("the resolvable threads MIME type should be valid")), + // Issues + qitem("application/vnd.github.starfire-preview+json".parse() + .expect("the issues MIME type should be valid")), + ]) + } + + /// Send a GraphQL query. + pub(crate) fn send<'de, Q>(&self, query: &QueryBody<Q::Variables>) -> Result<Q::ResponseData> + where Q: GraphQLQuery<'de>, + for<'d> Q::ResponseData: Deserialize<'d>, + { + let mut rsp = self.client + .post(self.gql_endpoint.clone()) + .header(self.installation_auth_header()?) + .header(self.gql_accept_headers()) + .header(UserAgent::new("ghostflow-github")) + .json(query) + .send() + .context(ErrorKind::SendRequest)?; + if !rsp.status().is_success() { + let err = rsp.text() + .unwrap_or_else(|text_err| { + format!("failed to extract error body: {:?}", + text_err) + }); + Err(ErrorKind::Github(err))?; + } + + let rsp: Response<Q::ResponseData> = rsp + .json() + .context(ErrorKind::Deserialize)?; + if let Some(errs) = rsp.errors { + Err(ErrorKind::from_gql(errs))?; + } + Ok(rsp.data + .ok_or_else(|| ErrorKind::NoResponse)?) + } } diff --git a/ghostflow-github/src/error.rs b/ghostflow-github/src/error.rs index 991b4753..9f00d0e1 100644 --- a/ghostflow-github/src/error.rs +++ b/ghostflow-github/src/error.rs @@ -7,6 +7,7 @@ // except according to those terms. use crates::failure::{Backtrace, Context, Fail}; +use crates::graphql_client::Error as GraphQLError; use std::fmt::{self, Display}; use std::result::Result as StdResult; @@ -30,11 +31,26 @@ pub(crate) enum ErrorKind { /// GitHub gave us back a failure. #[fail(display = "GitHub error: {}", _0)] Github(String), + /// GitHub gave us back a failure for a query. + #[fail(display = "GitHub GraphQL error: {:?}", _0)] + GithubGraphQL(Vec<String>), /// GitHub gave us back an empty result with no error messages. #[fail(display = "no response from GitHub")] NoResponse, } +impl ErrorKind { + /// Extract the message from a Github JSON error. + pub(crate) fn from_gql(errs: Vec<GraphQLError>) -> Self { + let errs = errs + .into_iter() + .map(|err| format!("{:?}", err)) + .collect(); + + ErrorKind::GithubGraphQL(errs) + } +} + /// An error within the GitHub ghostflow support. #[derive(Debug)] pub struct Error { -- GitLab From aa5acc1d2930f720dff9ff12b494349bf624e3c4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Thu, 13 Sep 2018 17:38:14 -0400 Subject: [PATCH 08/11] ghostflow: implement HostingService for GitHub --- ghostflow-github/Cargo.toml | 2 + ghostflow-github/src/ghostflow.rs | 1266 +++++++++++++++++++++++++++++ ghostflow-github/src/lib.rs | 5 + 3 files changed, 1273 insertions(+) create mode 100644 ghostflow-github/src/ghostflow.rs diff --git a/ghostflow-github/Cargo.toml b/ghostflow-github/Cargo.toml index d3cbe86d..49ae56fc 100644 --- a/ghostflow-github/Cargo.toml +++ b/ghostflow-github/Cargo.toml @@ -26,6 +26,8 @@ serde_json = "^1.0" ttl_cache = { git = "https://github.com/mathstuf/rust-ttl_cache.git", branch = "add-ttl-value" } failure = "~0.1" +ghostflow = { version = "~0.1", path = ".." } +git-workarea = "^3.0" serde = "^1.0" [dependencies.graphql_client] diff --git a/ghostflow-github/src/ghostflow.rs b/ghostflow-github/src/ghostflow.rs new file mode 100644 index 00000000..a6a518f0 --- /dev/null +++ b/ghostflow-github/src/ghostflow.rs @@ -0,0 +1,1266 @@ +// Copyright 2016 Kitware, Inc. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unreachable_code)] +#![allow(unused_variables)] + +use crates::chrono::Utc; +use crates::failure::ResultExt as FailureResultExt; +use crates::ghostflow::host::*; +use crates::git_workarea::CommitId; +use crates::graphql_client::GraphQLQuery; + +use std::fmt::{self, Debug}; + +use client::Github; +use queries; + +const WORK_IN_PROGRESS_PREFIXES: &[&str] = &[ + "WIP", + "wip", +]; + +impl From<queries::members::RepositoryPermission> for AccessLevel { + fn from(perms: queries::members::RepositoryPermission) -> Self { + use queries::members::RepositoryPermission; + match perms { + RepositoryPermission::ADMIN => AccessLevel::Owner, + RepositoryPermission::WRITE => AccessLevel::Maintainer, + RepositoryPermission::READ => AccessLevel::Developer, + RepositoryPermission::Other(_) => AccessLevel::Contributor, + } + } +} + +macro_rules! impl_from_reaction_content { + ($type:path) => { + impl From<$type> for String { + fn from(reaction: $type) -> Self { + use $type::*; + match reaction { + CONFUSED => "confused".to_string(), + HEART => "heart".to_string(), + HOORAY => "hooray".to_string(), + LAUGH => "laugh".to_string(), + THUMBS_DOWN => "-1".to_string(), + THUMBS_UP => "+1".to_string(), + Other(s) => s, + } + } + } + }; +} + +impl_from_reaction_content!(queries::pull_request_comment_reactions::ReactionContent); +impl_from_reaction_content!(queries::pull_request_reactions::ReactionContent); + +macro_rules! impl_into_reaction_content { + ($type:path) => { + impl<T> From<T> for $type + where + T: AsRef<str>, + { + fn from(reaction: T) -> Self { + use $type::*; + match reaction.as_ref() { + "confused" => CONFUSED, + "heart" => HEART, + "hooray" | "tada" => HOORAY, + "laugh" => LAUGH, + "-1" | "thumbs_down" => THUMBS_DOWN, + "+1" | "thumbs_up" => THUMBS_UP, + other => Other(other.to_string()), + } + } + } + }; +} + +impl_into_reaction_content!(queries::react_to_pull_request_comment::ReactionContent); + +macro_rules! impl_from_user_info { + ($type:path) => { + impl From<$type> for User { + fn from(user: $type) -> Self { + let $type { + name, + login, + // email, + } = user; + + Self { + name: name.unwrap_or_else(|| login.clone()), + // TODO(github-enterprise): What email to use here? + email: format!("{}@users.noreply.github.com", login), + handle: login, + } + } + } + }; +} + +impl_from_user_info!(queries::current_user::UserInfo); +impl_from_user_info!(queries::members::UserInfo); +impl_from_user_info!(queries::pull_request_comment_reactions::UserInfo); +impl_from_user_info!(queries::pull_request_comments::UserInfo); +impl_from_user_info!(queries::pull_request_reactions::UserInfo); +impl_from_user_info!(queries::user::UserInfo); + +macro_rules! impl_from_author_info { + ($type:path) => { + impl From<$type> for User { + fn from(author: $type) -> Self { + use $type::*; + match author { + Bot(bot) => { + Self { + handle: bot.login.clone(), + // TODO(github-enterprise): What email to use here? + email: format!("{}@users.noreply.github.com", bot.login), + name: bot.login, + } + }, + Organization(org) => { + // XXX(nll) + let login = org.login.clone(); + + Self { + name: org.name.unwrap_or_else(|| login.clone()), + email: org.email.unwrap_or_else(|| { + // TODO(github-enterprise): What email to use here? + format!("{}@users.noreply.github.com", login) + }), + handle: login, + } + }, + User(user) => { + // XXX(nll) + let login = user.login.clone(); + + Self { + name: user.name.unwrap_or_else(|| login.clone()), + email: if user.email.is_empty() { + // TODO(github-enterprise): What email to use here? + format!("{}@users.noreply.github.com", login) + } else { + user.email + }, + handle: login, + } + }, + } + } + } + }; +} + +impl_from_author_info!(queries::issue_comments::IssueCommentInfoAuthorOn); +impl_from_author_info!(queries::pull_request::PullRequestInfoAuthorOn); +impl_from_author_info!(queries::pull_request_comments::IssueCommentInfoAuthorOn); +impl_from_author_info!(queries::pull_request_comments::PullRequestReviewInfoAuthorOn); +impl_from_author_info!(queries::pull_request_comments::PullRequestReviewCommentInfoAuthorOn); + +macro_rules! impl_from_comment_info { + ($type:path) => { + impl From<$type> for Option<Comment> { + fn from(comment: $type) -> Self { + let $type { + id: comment_id, + author, + created_at, + content, + } = comment; + + author.map(|author| { + Comment { + id: comment_id, + is_system: false, + is_branch_update: false, + created_at: created_at, + author: author.on.into(), + content: content, + } + }) + } + } + }; +} + +impl_from_comment_info!(queries::issue_comments::IssueCommentInfo); +impl_from_comment_info!(queries::pull_request_comments::IssueCommentInfo); +impl_from_comment_info!(queries::pull_request_comments::PullRequestReviewInfo); +impl_from_comment_info!(queries::pull_request_comments::PullRequestReviewCommentInfo); + +impl From<queries::commit_statuses::CheckConclusionState> for CommitStatusState { + fn from(state: queries::commit_statuses::CheckConclusionState) -> Self { + use queries::commit_statuses::CheckConclusionState; + match state { + CheckConclusionState::ACTION_REQUIRED + | CheckConclusionState::FAILURE + | CheckConclusionState::TIMED_OUT => CommitStatusState::Failed, + CheckConclusionState::CANCELLED => CommitStatusState::Pending, + CheckConclusionState::NEUTRAL + | CheckConclusionState::SUCCESS => CommitStatusState::Success, + CheckConclusionState::Other(s) => { + error!( + target: "github", + "new GitHub conclusion state: {}", + s, + ); + CommitStatusState::Failed + }, + } + } +} + +fn extract_run_state(state: CommitStatusState) -> (queries::post_check_run::CheckConclusionState, queries::post_check_run::RequestableCheckStatusState) { + use queries::post_check_run::CheckConclusionState::*; + use queries::post_check_run::RequestableCheckStatusState::*; + match state { + CommitStatusState::Pending => (NEUTRAL, QUEUED), + CommitStatusState::Running => (NEUTRAL, IN_PROGRESS), + CommitStatusState::Success => (SUCCESS, COMPLETED), + CommitStatusState::Failed => (FAILURE, COMPLETED), + } +} + +fn github_summary_for_status(state: CommitStatusState) -> &'static str { + match state { + CommitStatusState::Pending => "Pending…", + CommitStatusState::Running => "Running…", + CommitStatusState::Success => "Success", + CommitStatusState::Failed => "Failure", + } +} + +/// Structure used to communicate with a Github instance. +/// +/// The API calls associated with this structure assume that the following permissions in GitHub +/// have been granted to the application: +/// +/// - Read & write +/// * Checks +/// * Repository contents +/// * Issues +/// * Pull requests +/// * Commit statuses +/// - Read-only +/// * Repository administration +/// * Repository metadata +/// * Organization members +/// +/// User permissions should include read-only access to email addresses. Note that this does not +/// currently work however and even with that permission, reading email addresses is being denied. +pub struct GithubService { + /// The Github client. + github: Github, + /// The user the service is acting as. + user: User, +} + +impl GithubService { + /// Create a new Github communication channel. + pub fn new(github: Github) -> Result<Self> { + let query = queries::CurrentUser::build_query(queries::current_user::Variables); + let user = github.send::<queries::CurrentUser>(&query) + .compat() + .chain_err(|| ErrorKind::Host)?; + + Ok(Self { + user: user.viewer.user_info.into(), + github: github, + }) + } + + /// Splits a project name in to an owner, name pair. + fn split_project(project: &str) -> Result<(&str, &str)> { + let mut split = project.split('/'); + if let Some(owner) = split.next() { + if let Some(name) = split.next() { + Ok((owner, name)) + } else { + Err(ErrorKind::Msg(format!("no repository name in '{}'", project)))? + } + } else { + Err(ErrorKind::Msg(format!("no owner name in '{}'", project)))? + } + } + + /// Create a repository from a Github project. + fn repo<R>(&self, project: R) -> Result<Repo> + where + R: queries::RepoInfo, + { + self.repo_impl(project.name(), project.ssh_url(), project.parent()) + } + + /// Create a repository from a Github project. + fn repo_impl(&self, name: String, ssh_url: &str, parent: Option<(&str, &str)>) -> Result<Repo> { + let parent_project = if let Some((owner, name)) = parent { + let vars = queries::repository::Variables { + owner: owner.to_string(), + name: name.to_string(), + }; + let query = queries::Repository::build_query(vars); + let parent_project = self.github + .send::<queries::Repository>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", name)))?) + })? + .repo_info; + Some(Box::new(self.repo(parent_project)?)) + } else { + None + }; + + Ok(Repo { + name: name, + url: ssh_url.to_string(), + forked_from: parent_project, + }) + } + + /// Create a comment. + fn post_comment<C>(&self, id: String, content: C) -> Result<()> + where + C: ToString, + { + let input = queries::post_comment::Variables { + input: queries::post_comment::AddCommentInput { + client_mutation_id: Some(self.github.client_id().to_string()), + subject_id: id, + body: content.to_string(), + }, + }; + let mutation = queries::PostComment::build_query(input); + self.github + .send::<queries::PostComment>(&mutation) + .compat() + .chain_err(|| ErrorKind::Host)?; + + Ok(()) + } + + /// Create a check run. + fn post_check_run(&self, status: PendingCommitStatus, description: Option<String>) -> Result<()> { + let project = &status.commit.repo.name; + let (owner, name) = Self::split_project(project)?; + + let vars = queries::repository_id::Variables { + owner: owner.to_string(), + name: name.to_string(), + }; + let query = queries::RepositoryID::build_query(vars); + let repository_id = self.github + .send::<queries::RepositoryID>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + })? + .id; + + let (conclusion, status_state) = extract_run_state(status.state); + let input = queries::post_check_run::Variables { + input: queries::post_check_run::CreateCheckRunInput { + client_mutation_id: Some(self.github.client_id().to_string()), + actions: None, + completed_at: Some(Utc::now()), + conclusion: Some(conclusion), + details_url: None, + external_id: None, + head_sha: status.commit.id.as_str().to_string(), + name: status.name.to_string(), + output: Some(queries::post_check_run::CheckRunOutput { + annotations: None, + images: None, + summary: github_summary_for_status(status.state).to_string(), + text: description, + title: status.name.to_string(), + }), + repository_id: repository_id, + started_at: None, + status: Some(status_state), + }, + }; + let mutation = queries::PostCheckRun::build_query(input); + self.github + .send::<queries::PostCheckRun>(&mutation) + .compat() + .chain_err(|| ErrorKind::Host)?; + + Ok(()) + } +} + +impl HostingService for GithubService { + fn service_user(&self) -> &User { + &self.user + } + + fn add_member(&self, _project: &str, _user: &User, _level: AccessLevel) -> Result<()> { + // XXX(github): Github only supports inviting users to repositories. + Err(ErrorKind::Msg("GitHub does not support adding members to projects.".to_string()))? + } + + fn members(&self, project: &str) -> Result<Vec<Membership>> { + let (owner, name) = Self::split_project(project)?; + + let mut vars = queries::members::Variables { + owner: owner.to_string(), + name: name.to_string(), + cursor: None, + }; + + let mut members = Vec::new(); + loop { + let query = queries::Members::build_query(vars.clone()); + let page_collaborators = self + .github + .send::<queries::Members>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| format!("no repository '{}'", project))?) + }) + .and_then(|rsp| { + Ok(rsp.collaborators + .ok_or_else(|| format!("no repository collaborators '{}'", project))?) + })?; + let (collaborators, page_info) = ( + page_collaborators.members + .ok_or_else(|| format!("no repository collaborator edges '{}'", project))?, + page_collaborators.page_info, + ); + + members.extend( + collaborators.into_iter() + .filter_map(|collaborator| { + collaborator.map(|collaborator| { + Membership { + user: collaborator.user.user_info.into(), + access_level: collaborator.permission.into(), + expiration: None, + } + }) + }) + ); + + if page_info.has_next_page { + // XXX: We are assuming that if `has_next_page` is `true` that we'll have an + // `end_cursor`. + assert!( + page_info.end_cursor.is_some(), + "GitHub gave us a new page without a cursor to follow.", + ); + vars.cursor = page_info.end_cursor; + } else { + break; + } + } + + Ok(members) + } + + fn add_hook(&self, _project: &str, _url: &str) -> Result<()> { + // XXX(github): Github only supports "integrations". + Err(ErrorKind::Msg("GitHub does not support adding hooks to projects.".to_string()))? + } + + fn user(&self, user: &str) -> Result<User> { + let vars = queries::user::Variables { + name: user.to_string(), + }; + let query = queries::User::build_query(vars); + Ok(self.github + .send::<queries::User>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.user + .ok_or_else(|| ErrorKind::Msg(format!("no user '{}'", user)))?) + })? + .user_info + .into()) + } + + fn commit(&self, project: &str, commit: &CommitId) -> Result<Commit> { + let (owner, name) = Self::split_project(project)?; + + let vars = queries::commit::Variables { + owner: owner.to_string(), + name: name.to_string(), + commit: commit.as_str().to_string(), + }; + let query = queries::Commit::build_query(vars); + Ok(self.github + .send::<queries::Commit>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|repo| { + Ok(repo.object + .ok_or_else(|| ErrorKind::Msg(format!("no object for '{}@{}'", project, commit.as_str())))?) + }) + .and_then(|object| { + let (repo, oid, object) = (object.repository.repo_info, object.oid, object.on); + + use queries::commit::RustCommitRepositoryObjectOn; + let oid = if let RustCommitRepositoryObjectOn::Commit = object { + oid + } else { + Err(ErrorKind::Msg(format!("not a commit: '{}@{}'", project, commit.as_str())))? + }; + + Ok(Commit { + repo: self.repo(repo)?, + refname: None, + id: CommitId::new(oid), + }) + })?) + } + + fn issue(&self, project: &str, id: u64) -> Result<Issue> { + let (owner, name) = Self::split_project(project)?; + + let vars = queries::issue::Variables { + owner: owner.to_string(), + name: name.to_string(), + issue: id as i64, + }; + let query = queries::Issue::build_query(vars); + Ok(self.github + .send::<queries::Issue>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|repo| { + Ok(repo.issue + .ok_or_else(|| ErrorKind::Msg(format!("no issue for '{}#{}'", project, id)))? + .issue_info) + }) + .and_then(|issue| { + Ok(Issue { + repo: self.repo(issue.repository.repo_info)?, + id: id, + url: issue.url, + description: issue.description, + labels: issue.labels + .and_then(|opt_labels| opt_labels.labels) + .map(|labels| { + labels.into_iter() + .filter_map(|opt_label| opt_label) + .map(|label| label.name) + .collect() + }) + .unwrap_or_else(Vec::new), + milestone: issue.milestone.map(|milestone| milestone.title), + assignee: issue.assignees.assignees + .and_then(|assignees| { + assignees.into_iter() + .filter_map(|opt_assignee| opt_assignee) + .next() + .map(|assignee| assignee.login) + }), + reference: format!("#{}", id), + }) + })?) + } + + fn merge_request(&self, project: &str, id: u64) -> Result<MergeRequest> { + let (owner, name) = Self::split_project(project)?; + + let vars = queries::pull_request::Variables { + owner: owner.to_string(), + name: name.to_string(), + pull: id as i64, + }; + let query = queries::PullRequest::build_query(vars); + Ok(self.github + .send::<queries::PullRequest>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|repo| { + Ok(repo.pull_request + .ok_or_else(|| ErrorKind::Msg(format!("no pull for '{}#{}'", project, id)))? + .pull_request_info) + }) + .and_then(|pull| { + let queries::pull_request::PullRequestInfo { + source_repo, + source_branch, + target_repo, + target_branch, + url, + title, + description, + head_ref_oid, + author, + } = pull; + + let target_repo = self.repo(target_repo.repo_info)?; + + Ok(MergeRequest { + // TODO(github): Is this `None` if the source repo is also the target repo? + // There is an `isCrossRepository` flag on pull requests. + source_repo: self.repo(source_repo + .ok_or_else(|| ErrorKind::Msg(format!("source repo deleted for '{}#{}'", project, id)))? + .repo_info)?, + source_branch: source_branch.clone(), + target_repo: target_repo.clone(), + target_branch: target_branch, + id: id, + url: url, + work_in_progress: WORK_IN_PROGRESS_PREFIXES + .iter() + .any(|prefix| title.starts_with(prefix)), + description: description, + old_commit: None, + commit: Commit { + repo: target_repo, + refname: Some(source_branch), + id: CommitId::new(head_ref_oid), + }, + author: author + .ok_or_else(|| ErrorKind::Msg(format!("no author of pull for '{}#{}'", project, id)))? + .on + .into(), + reference: format!("#{}", id), + remove_source_branch: false, + }) + })?) + } + + fn repo(&self, project: &str) -> Result<Repo> { + let (owner, name) = Self::split_project(project)?; + + let vars = queries::repository::Variables { + owner: owner.to_string(), + name: name.to_string(), + }; + let query = queries::Repository::build_query(vars); + self.repo(self.github + .send::<queries::Repository>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + })? + .repo_info) + } + + fn get_issue_comments(&self, issue: &Issue) -> Result<Vec<Comment>> { + let project = &issue.repo.name; + let id = issue.id; + let (owner, name) = Self::split_project(project)?; + + let mut vars = queries::issue_comments::Variables { + owner: owner.to_string(), + name: name.to_string(), + id: id as i64, + cursor: None, + }; + + let mut comments = Vec::new(); + loop { + let query = queries::IssueComments::build_query(vars.clone()); + let page_timeline = self.github + .send::<queries::IssueComments>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.issue + .ok_or_else(|| ErrorKind::Msg(format!("no issue for '{}#{}'", project, id)))?) + })? + .timeline; + let (items, page_info) = ( + page_timeline.items + .ok_or_else(|| format!("no issue timeline edges '{}#{}'", project, id))?, + page_timeline.page_info, + ); + + comments.extend( + items.into_iter() + .filter_map(|item| { + use queries::issue_comments::RustIssueCommentsRepositoryIssueTimelineItems::*; + if let Some(IssueComment(comment)) = item { + comment.issue_comment_info.into() + } else { + None + } + }) + ); + + if page_info.has_next_page { + // XXX: We are assuming that if `has_next_page` is `true` that we'll have an + // `end_cursor`. + assert!( + page_info.end_cursor.is_some(), + "GitHub gave us a new page without a cursor to follow.", + ); + vars.cursor = page_info.end_cursor; + } else { + break; + } + } + + Ok(comments) + } + + fn post_issue_comment(&self, issue: &Issue, content: &str) -> Result<()> { + let project = &issue.repo.name; + let id = issue.id; + let (owner, name) = Self::split_project(project)?; + + let vars = queries::issue_id::Variables { + owner: owner.to_string(), + name: name.to_string(), + issue: id as i64, + }; + let query = queries::IssueID::build_query(vars); + let issue_id = self.github + .send::<queries::IssueID>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.issue + .ok_or_else(|| ErrorKind::Msg(format!("no issue for '{}#{}'", project, id)))?) + })? + .id; + + self.post_comment(issue_id, content) + } + + fn get_mr_comments(&self, mr: &MergeRequest) -> Result<Vec<Comment>> { + let project = &mr.target_repo.name; + let id = mr.id; + let (owner, name) = Self::split_project(project)?; + + let mut vars = queries::pull_request_comments::Variables { + owner: owner.to_string(), + name: name.to_string(), + pull: id as i64, + cursor: None, + }; + + let mut comments = Vec::new(); + loop { + let query = queries::PullRequestComments::build_query(vars.clone()); + let page_timeline = self.github + .send::<queries::PullRequestComments>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::PullRequestComments::name()); + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.pull_request + .ok_or_else(|| ErrorKind::Msg(format!("no pull for '{}#{}'", project, id)))?) + })? + .timeline; + let (items, page_info) = ( + page_timeline.items + .ok_or_else(|| format!("no pull timeline edges '{}#{}'", project, id))?, + page_timeline.page_info, + ); + + comments.extend( + items.into_iter() + .filter_map(|item| { + use queries::pull_request_comments::RustPullRequestCommentsRepositoryPullRequestTimelineItems::*; + match item { + Some(Commit(commit)) => { + // XXX(github): We really want `Push` events here. We're just + // going to do what we can in the meantime however. + let queries::pull_request_comments::RustPullRequestCommentsRepositoryPullRequestTimelineItemsOnCommit { + id: commit_id, + pushed_date, + committed_date, + author, + message, + } = commit; + + author.map(|author| { + let queries::pull_request_comments::RustPullRequestCommentsRepositoryPullRequestTimelineItemsOnCommitAuthor { + user, + name, + email, + } = author; + + Comment { + id: commit_id, + is_system: true, + is_branch_update: pushed_date.is_some(), + // This is a poor replacement for `pushedDate`, but it's + // the best we have. + created_at: pushed_date.unwrap_or(committed_date), + author: user.map(|user| user.user_info.into()) + .unwrap_or_else(|| { + // XXX(github): We can't really drop things just + // because we don't have data since the glostflow + // code expects to be able to find when the last + // push happened and these "comments" fulfill that + // use case. If anything is missing, just use who + // we are communicating as. + User { + name: name.unwrap_or_else(|| self.user.name.clone()), + email: email.unwrap_or_else(|| self.user.name.clone()), + handle: self.user.handle.clone(), + } + }), + content: message, + } + }) + }, + Some(IssueComment(comment)) => { + comment.issue_comment_info.into() + }, + Some(PullRequestReview(review)) => { + review.pull_request_review_info.into() + }, + Some(PullRequestReviewComment(comment)) => { + comment.pull_request_review_comment_info.into() + }, + _ => None, + } + }) + ); + + if page_info.has_next_page { + // XXX: We are assuming that if `has_next_page` is `true` that we'll have an + // `end_cursor`. + assert!( + page_info.end_cursor.is_some(), + "GitHub gave us a new page without a cursor to follow.", + ); + vars.cursor = page_info.end_cursor; + } else { + break; + } + } + + Ok(comments) + } + + fn post_mr_comment(&self, mr: &MergeRequest, content: &str) -> Result<()> { + let project = &mr.target_repo.name; + let id = mr.id; + let (owner, name) = Self::split_project(project)?; + + let vars = queries::pull_request_id::Variables { + owner: owner.to_string(), + name: name.to_string(), + pull: id as i64, + }; + let query = queries::PullRequestID::build_query(vars); + let pull_request_id = self.github + .send::<queries::PullRequestID>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.pull_request + .ok_or_else(|| ErrorKind::Msg(format!("no pull for '{}#{}'", project, id)))?) + })? + .id; + + self.post_comment(pull_request_id, content) + } + + fn post_commit_comment(&self, commit: &Commit, content: &str) -> Result<()> { + let project = &commit.repo.name; + let oid = &commit.id; + let (owner, name) = Self::split_project(project)?; + + let vars = queries::commit_id::Variables { + owner: owner.to_string(), + name: name.to_string(), + commit: oid.as_str().to_string(), + }; + let query = queries::CommitID::build_query(vars); + let comment_id = self.github + .send::<queries::CommitID>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.object + .ok_or_else(|| ErrorKind::Msg(format!("no object for '{}@{}'", project, oid)))?) + }) + .and_then(|rsp| { + use queries::commit_id::RustCommitIdRepositoryObjectOn; + if let RustCommitIdRepositoryObjectOn::Commit(commit) = rsp.on { + Ok(commit.id) + } else { + Err(ErrorKind::Msg(format!("'{}@{}' is not a commit", project, oid)))? + } + })?; + + self.post_comment(comment_id, content) + } + + fn get_commit_statuses(&self, commit: &Commit) -> Result<Vec<CommitStatus>> { + let project = &commit.repo.name; + let oid = commit.id.as_str(); + let (owner, name) = Self::split_project(project)?; + + let vars = queries::commit_statuses::Variables { + owner: owner.to_string(), + name: name.to_string(), + commit: oid.to_string(), + app_id: self.github.app_id(), + }; + + let query = queries::CommitStatuses::build_query(vars.clone()); + let check_suite = self.github + .send::<queries::CommitStatuses>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + let object = rsp.object + .ok_or_else(|| ErrorKind::Msg(format!("no object for '{}@{}'", project, oid)))?; + + use queries::commit_statuses::RustCommitStatusesRepositoryObjectOn; + if let RustCommitStatusesRepositoryObjectOn::Commit(commit) = object.on { + Ok(commit) + } else { + Err(ErrorKind::Msg(format!("object '{}@{}' is not a commit", project, oid)))? + } + })? + .check_suites + .and_then(|check_suites| check_suites.check_suite) + .unwrap_or_else(Vec::new) + .into_iter() + .next() + .and_then(|check_suite| check_suite); + let check_suite = if let Some(check_suite) = check_suite { + check_suite + } else { + return Ok(Vec::new()); + }; + let (branch, check_runs) = ( + check_suite.branch.map(|branch| branch.name), + check_suite.check_runs + .and_then(|check_runs| check_runs.check_runs) + .unwrap_or_else(Vec::new), + ); + + Ok(check_runs.into_iter() + .filter_map(|check_run| { + check_run.and_then(|check_run| { + let queries::commit_statuses::RustCommitStatusesRepositoryObjectOnCommitCheckSuitesCheckSuiteCheckRunsCheckRuns { + conclusion, + name, + summary, + } = check_run; + + conclusion.map(|conclusion| { + CommitStatus { + state: conclusion.into(), + author: self.user.clone(), + refname: branch.clone(), + name: name, + description: summary.unwrap_or_else(String::new), + } + }) + }) + }) + .collect()) + } + + fn post_commit_status(&self, status: PendingCommitStatus) -> Result<()> { + self.post_check_run(status, None) + } + + fn post_review(&self, status: PendingCommitStatus, _: &MergeRequest, description: &str) -> Result<()> { + self.post_check_run(status, Some(description.to_string())) + } + + fn get_mr_awards(&self, mr: &MergeRequest) -> Result<Vec<Award>> { + let project = &mr.target_repo.name; + let id = mr.id; + let (owner, name) = Self::split_project(project)?; + + let mut vars = queries::pull_request_reactions::Variables { + owner: owner.to_string(), + name: name.to_string(), + pull: id as i64, + cursor: None, + }; + + let mut awards = Vec::new(); + loop { + let query = queries::PullRequestReactions::build_query(vars.clone()); + let page_reactions = self.github + .send::<queries::PullRequestReactions>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.pull_request + .ok_or_else(|| ErrorKind::Msg(format!("no pull for '{}#{}'", project, id)))?) + })? + .reactions; + let (reactions, page_info) = ( + page_reactions.reactions + .ok_or_else(|| format!("no pull reaction edges '{}#{}'", project, id))?, + page_reactions.page_info, + ); + + awards.extend( + reactions.into_iter() + .filter_map(|reaction| { + reaction.and_then(|reaction| { + let queries::pull_request_reactions::RustPullRequestReactionsRepositoryPullRequestReactionsReactions { + typename: _, + content, + user, + } = reaction; + + user.map(|user| { + Award { + name: content.into(), + author: user.user_info.into(), + } + }) + }) + }) + ); + + if page_info.has_next_page { + // XXX: We are assuming that if `has_next_page` is `true` that we'll have an + // `end_cursor`. + assert!( + page_info.end_cursor.is_some(), + "GitHub gave us a new page without a cursor to follow.", + ); + vars.cursor = page_info.end_cursor; + } else { + break; + } + } + + Ok(awards) + } + + fn get_mr_comment_awards(&self, _: &MergeRequest, comment: &Comment) -> Result<Vec<Award>> { + let id = &comment.id; + let mut vars = queries::pull_request_comment_reactions::Variables { + id: id.clone(), + cursor: None, + }; + + let mut awards = Vec::new(); + loop { + let query = queries::PullRequestCommentReactions::build_query(vars.clone()); + let page_reactions = self.github + .send::<queries::PullRequestCommentReactions>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.node + .ok_or_else(|| ErrorKind::Msg(format!("no node for comment '{}'", id)))?) + }) + .and_then(|rsp| { + use queries::pull_request_comment_reactions::RustPullRequestCommentReactionsNodeOn; + if let RustPullRequestCommentReactionsNodeOn::IssueComment(comment) = rsp.on { + Ok(comment) + } else { + Err(ErrorKind::Msg(format!("node '{}' is not an issue comment", id)))? + } + })? + .reactions; + let (reactions, page_info) = ( + page_reactions.reactions + .ok_or_else(|| format!("no comment reaction edges '{}'", id))?, + page_reactions.page_info, + ); + + awards.extend( + reactions.into_iter() + .filter_map(|reaction| { + reaction.and_then(|reaction| { + let queries::pull_request_comment_reactions::RustPullRequestCommentReactionsNodeOnIssueCommentReactionsReactions { + typename: _, + content, + user, + } = reaction; + + user.map(|user| { + Award { + name: content.into(), + author: user.user_info.into(), + } + }) + }) + }) + ); + + if page_info.has_next_page { + // XXX: We are assuming that if `has_next_page` is `true` that we'll have an + // `end_cursor`. + assert!( + page_info.end_cursor.is_some(), + "GitHub gave us a new page without a cursor to follow.", + ); + vars.cursor = page_info.end_cursor; + } else { + break; + } + } + + Ok(awards) + } + + fn award_mr_comment(&self, _: &MergeRequest, comment: &Comment, award: &str) -> Result<()> { + let id = &comment.id; + + use queries::react_to_pull_request_comment::ReactionContent; + let content = match award.into() { + ReactionContent::Other(s) => { + Err(ErrorKind::Msg(format!("unrecognized award name '{}'", award)))? + }, + award => award, + }; + let vars = queries::react_to_pull_request_comment::Variables { + input: queries::react_to_pull_request_comment::AddReactionInput { + client_mutation_id: Some(self.github.client_id().to_string()), + subject_id: id.clone(), + content: content, + }, + }; + let mutation = queries::ReactToPullRequestComment::build_query(vars); + self.github + .send::<queries::ReactToPullRequestComment>(&mutation) + .compat() + .chain_err(|| ErrorKind::Host)?; + + Ok(()) + } + + fn issues_closed_by_mr(&self, _mr: &MergeRequest) -> Result<Vec<Issue>> { + // XXX: No API endpoint right now. Request sent to Github. + Ok(Vec::new()) + } + + fn add_issue_labels(&self, issue: &Issue, labels: &[&str]) -> Result<()> { + let project = &issue.repo.name; + let id = issue.id; + let (owner, name) = Self::split_project(project)?; + + let vars = queries::issue_id::Variables { + owner: owner.to_string(), + name: name.to_string(), + issue: id as i64, + }; + let query = queries::IssueID::build_query(vars); + let issue_id = self.github + .send::<queries::IssueID>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.issue + .ok_or_else(|| ErrorKind::Msg(format!("no issue for '{}#{}'", project, id)))?) + })? + .id; + + let label_ids = labels.iter() + .map(|label| { + let vars = queries::label_id::Variables { + owner: owner.to_string(), + name: name.to_string(), + label: label.to_string(), + }; + let query = queries::LabelID::build_query(vars); + Ok(self.github + .send::<queries::LabelID>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) + }) + .and_then(|rsp| { + Ok(rsp.label + .ok_or_else(|| ErrorKind::Msg(format!("no label '{}' on '{}'", label, project)))?) + })? + .id) + }) + .collect::<Result<_>>()?; + + let input = queries::add_issue_labels::Variables { + input: queries::add_issue_labels::AddLabelsToLabelableInput { + client_mutation_id: Some(self.github.client_id().to_string()), + label_ids: label_ids, + labelable_id: issue_id, + }, + }; + let mutation = queries::AddIssueLabels::build_query(input); + self.github + .send::<queries::AddIssueLabels>(&mutation) + .compat() + .chain_err(|| ErrorKind::Host)?; + + Ok(()) + } + + fn comment_award_name(&self) -> &str { + "hooray" + } +} + +impl Debug for GithubService { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("GithubService") + .field("user", &self.user.handle) + .finish() + } +} diff --git a/ghostflow-github/src/lib.rs b/ghostflow-github/src/lib.rs index b502357c..44ffb5fc 100644 --- a/ghostflow-github/src/lib.rs +++ b/ghostflow-github/src/lib.rs @@ -29,6 +29,8 @@ mod crates { pub extern crate serde_json; pub extern crate failure; + pub extern crate ghostflow; + pub extern crate git_workarea; pub extern crate serde; } @@ -39,3 +41,6 @@ use crates::serde; pub(crate) mod queries; mod client; pub use client::Github; + +mod ghostflow; +pub use ghostflow::GithubService; -- GitLab From f0f2b75c6185f10c01bd00fec109b2e2d06b95f7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Fri, 14 Sep 2018 14:01:50 -0400 Subject: [PATCH 09/11] github: unroll one level of repository queries Most forks are only one connection away from their roots. Unroll the parentage queries by one to help reduce the number of connections we need to make. --- ghostflow-github/src/ghostflow.rs | 49 +++++++++++++++------- ghostflow-github/src/graphql/query.graphql | 8 ++++ ghostflow-github/src/queries.rs | 26 ++++++++++-- 3 files changed, 64 insertions(+), 19 deletions(-) diff --git a/ghostflow-github/src/ghostflow.rs b/ghostflow-github/src/ghostflow.rs index a6a518f0..e11f88a3 100644 --- a/ghostflow-github/src/ghostflow.rs +++ b/ghostflow-github/src/ghostflow.rs @@ -300,23 +300,40 @@ impl GithubService { } /// Create a repository from a Github project. - fn repo_impl(&self, name: String, ssh_url: &str, parent: Option<(&str, &str)>) -> Result<Repo> { - let parent_project = if let Some((owner, name)) = parent { - let vars = queries::repository::Variables { - owner: owner.to_string(), - name: name.to_string(), + fn repo_impl(&self, name: String, ssh_url: &str, parent: Option<queries::RepoParentInfo>) -> Result<Repo> { + let parent_project = if let Some(parent_info) = parent { + let queries::RepoParentInfo { + owner, + name, + ssh_url, + parent: grand_parent, + } = parent_info; + + let grand_parent = if let Some((owner, name)) = grand_parent { + let vars = queries::repository::Variables { + owner: owner.to_string(), + name: name.to_string(), + }; + let query = queries::Repository::build_query(vars); + let grand_parent_project = self.github + .send::<queries::Repository>(&query) + .compat() + .chain_err(|| ErrorKind::Host) + .and_then(|rsp| { + Ok(rsp.repository + .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", name)))?) + })? + .repo_info; + Some(Box::new(self.repo(grand_parent_project)?)) + } else { + None }; - let query = queries::Repository::build_query(vars); - let parent_project = self.github - .send::<queries::Repository>(&query) - .compat() - .chain_err(|| ErrorKind::Host) - .and_then(|rsp| { - Ok(rsp.repository - .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", name)))?) - })? - .repo_info; - Some(Box::new(self.repo(parent_project)?)) + + Some(Box::new(Repo { + name: format!("{}/{}", owner, name), + url: ssh_url.to_string(), + forked_from: grand_parent, + })) } else { None }; diff --git a/ghostflow-github/src/graphql/query.graphql b/ghostflow-github/src/graphql/query.graphql index 33197d8e..36046df2 100644 --- a/ghostflow-github/src/graphql/query.graphql +++ b/ghostflow-github/src/graphql/query.graphql @@ -43,6 +43,14 @@ fragment RepoInfo on Repository { login } name + sshUrl + parent { + owner { + __typename + login + } + name + } #...RepoInfo } } diff --git a/ghostflow-github/src/queries.rs b/ghostflow-github/src/queries.rs index df810867..295a11da 100644 --- a/ghostflow-github/src/queries.rs +++ b/ghostflow-github/src/queries.rs @@ -53,10 +53,17 @@ gql_query!(PostCheckRun); gql_query!(ReactToPullRequestComment); gql_query!(AddIssueLabels); +pub(crate) struct RepoParentInfo<'a> { + pub owner: &'a str, + pub name: &'a str, + pub ssh_url: &'a str, + pub parent: Option<(&'a str, &'a str)>, +} + pub(crate) trait RepoInfo { fn name(&self) -> String; fn ssh_url(&self) -> &str; - fn parent(&self) -> Option<(&str, &str)>; + fn parent(&self) -> Option<RepoParentInfo>; } macro_rules! impl_repo_info { @@ -70,8 +77,21 @@ macro_rules! impl_repo_info { &self.ssh_url } - fn parent(&self) -> Option<(&str, &str)> { - self.parent.as_ref().map(|parent| (parent.owner.login.as_ref(), parent.name.as_ref())) + fn parent(&self) -> Option<RepoParentInfo> { + self.parent + .as_ref() + .map(|parent| { + RepoParentInfo { + owner: &parent.owner.login, + name: &parent.name, + ssh_url: &parent.ssh_url.as_ref(), + parent: parent.parent + .as_ref() + .map(|grandparent| { + (grandparent.owner.login.as_ref(), grandparent.name.as_ref()) + }), + } + }) } } }; -- GitLab From e4f76e2fb48e04751da847ca6ad1f60968e4c72a Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Fri, 14 Sep 2018 14:51:53 -0400 Subject: [PATCH 10/11] github: log rate limit statistics --- ghostflow-github/src/ghostflow.rs | 26 ++++ ghostflow-github/src/graphql/query.graphql | 26 ++++ ghostflow-github/src/lib.rs | 1 + ghostflow-github/src/queries.rs | 158 +++++++++++++++++---- 4 files changed, 187 insertions(+), 24 deletions(-) diff --git a/ghostflow-github/src/ghostflow.rs b/ghostflow-github/src/ghostflow.rs index e11f88a3..52edc1d9 100644 --- a/ghostflow-github/src/ghostflow.rs +++ b/ghostflow-github/src/ghostflow.rs @@ -271,6 +271,8 @@ impl GithubService { .compat() .chain_err(|| ErrorKind::Host)?; + Self::check_rate_limits(&user.rate_limit_info.rate_limit, queries::CurrentUser::name()); + Ok(Self { user: user.viewer.user_info.into(), github: github, @@ -381,6 +383,7 @@ impl GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::RepositoryID::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) })? @@ -417,6 +420,14 @@ impl GithubService { Ok(()) } + + /// Check the rate limiting for a query. + fn check_rate_limits<R>(rate_limit: &Option<R>, name: &str) + where + R: Into<queries::RateLimitInfo> + Clone, + { + rate_limit.as_ref().map(|info| info.clone().into().inspect(name)); + } } impl HostingService for GithubService { @@ -447,6 +458,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::Members::name()); Ok(rsp.repository .ok_or_else(|| format!("no repository '{}'", project))?) }) @@ -504,6 +516,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::User::name()); Ok(rsp.user .ok_or_else(|| ErrorKind::Msg(format!("no user '{}'", user)))?) })? @@ -525,6 +538,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::Commit::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -564,6 +578,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::Issue::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -614,6 +629,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::PullRequest::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -681,6 +697,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::Repository::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) })? @@ -707,6 +724,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::IssueComments::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -765,6 +783,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::IssueID::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -906,6 +925,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::PullRequestID::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -934,6 +954,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::CommitID::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -971,6 +992,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::CommitStatuses::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -1054,6 +1076,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::PullRequestReactions::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -1119,6 +1142,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::PullRequestCommentReactions::name()); Ok(rsp.node .ok_or_else(|| ErrorKind::Msg(format!("no node for comment '{}'", id)))?) }) @@ -1220,6 +1244,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::IssueID::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) @@ -1242,6 +1267,7 @@ impl HostingService for GithubService { .compat() .chain_err(|| ErrorKind::Host) .and_then(|rsp| { + Self::check_rate_limits(&rsp.rate_limit_info.rate_limit, queries::LabelID::name()); Ok(rsp.repository .ok_or_else(|| ErrorKind::Msg(format!("no repository for '{}'", project)))?) }) diff --git a/ghostflow-github/src/graphql/query.graphql b/ghostflow-github/src/graphql/query.graphql index 36046df2..f9ff91a5 100644 --- a/ghostflow-github/src/graphql/query.graphql +++ b/ghostflow-github/src/graphql/query.graphql @@ -55,6 +55,15 @@ fragment RepoInfo on Repository { } } +fragment RateLimitInfo on Query { + rateLimit { + cost + limit + remaining + resetAt + } +} + fragment IssueInfo on Issue { repository { ...RepoInfo @@ -206,6 +215,7 @@ query CurrentUser { viewer { ...UserInfo } + ...RateLimitInfo } query Members($owner: String!, $name: String!, $cursor: String) { @@ -223,12 +233,14 @@ query Members($owner: String!, $name: String!, $cursor: String) { } } } + ...RateLimitInfo } query User($name: String!) { user(login: $name) { ...UserInfo } + ...RateLimitInfo } query Commit($owner: String!, $name: String!, $commit: GitObjectID!) { @@ -241,6 +253,7 @@ query Commit($owner: String!, $name: String!, $commit: GitObjectID!) { oid } } + ...RateLimitInfo } query Issue($owner: String!, $name: String!, $issue: Int!) { @@ -249,6 +262,7 @@ query Issue($owner: String!, $name: String!, $issue: Int!) { ...IssueInfo } } + ...RateLimitInfo } query PullRequest($owner: String!, $name: String!, $pull: Int!) { @@ -257,12 +271,14 @@ query PullRequest($owner: String!, $name: String!, $pull: Int!) { ...PullRequestInfo } } + ...RateLimitInfo } query Repository($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { ...RepoInfo } + ...RateLimitInfo } query IssueComments($owner: String!, $name: String!, $id: Int!, $cursor: String) { @@ -282,6 +298,7 @@ query IssueComments($owner: String!, $name: String!, $id: Int!, $cursor: String) } } } + ...RateLimitInfo } query IssueID($owner: String!, $name: String!, $issue: Int!) { @@ -290,6 +307,7 @@ query IssueID($owner: String!, $name: String!, $issue: Int!) { id } } + ...RateLimitInfo } mutation PostComment($input: AddCommentInput!) { @@ -337,6 +355,7 @@ query PullRequestComments($owner: String!, $name: String!, $pull: Int!, $cursor: } } } + ...RateLimitInfo } query PullRequestID($owner: String!, $name: String!, $pull: Int!) { @@ -345,6 +364,7 @@ query PullRequestID($owner: String!, $name: String!, $pull: Int!) { id } } + ...RateLimitInfo } query CommitID($owner: String!, $name: String!, $commit: GitObjectID!) { @@ -356,6 +376,7 @@ query CommitID($owner: String!, $name: String!, $commit: GitObjectID!) { } } } + ...RateLimitInfo } query CommitStatuses($owner: String!, $name: String!, $commit: GitObjectID!, $appId: Int!) { @@ -385,12 +406,14 @@ query CommitStatuses($owner: String!, $name: String!, $commit: GitObjectID!, $ap } } } + ...RateLimitInfo } query RepositoryID($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { id } + ...RateLimitInfo } mutation PostCheckRun($input: CreateCheckRunInput!) { @@ -418,6 +441,7 @@ query PullRequestReactions($owner: String!, $name: String!, $pull: Int!, $cursor } } } + ...RateLimitInfo } query PullRequestCommentReactions($id: ID!, $cursor: String) { @@ -439,6 +463,7 @@ query PullRequestCommentReactions($id: ID!, $cursor: String) { } } } + ...RateLimitInfo } mutation ReactToPullRequestComment($input: AddReactionInput!) { @@ -458,6 +483,7 @@ query LabelID($owner: String!, $name: String!, $label: String!) { id } } + ...RateLimitInfo } mutation AddIssueLabels($input: AddLabelsToLabelableInput!) { diff --git a/ghostflow-github/src/lib.rs b/ghostflow-github/src/lib.rs index 44ffb5fc..a57752e5 100644 --- a/ghostflow-github/src/lib.rs +++ b/ghostflow-github/src/lib.rs @@ -31,6 +31,7 @@ mod crates { pub extern crate failure; pub extern crate ghostflow; pub extern crate git_workarea; + pub extern crate log; pub extern crate serde; } diff --git a/ghostflow-github/src/queries.rs b/ghostflow-github/src/queries.rs index 295a11da..b4de0856 100644 --- a/ghostflow-github/src/queries.rs +++ b/ghostflow-github/src/queries.rs @@ -10,13 +10,14 @@ #![allow(unused_imports)] use crates::chrono::{self, Utc}; +use crates::log::Level; type DateTime = chrono::DateTime<Utc>; type GitObjectID = String; type GitSSHRemote = String; type URI = String; -macro_rules! gql_query { +macro_rules! gql_query_base { ($name:ident) => { #[derive(GraphQLQuery)] #[graphql( @@ -29,29 +30,47 @@ macro_rules! gql_query { }; } -gql_query!(CurrentUser); -gql_query!(Members); -gql_query!(User); -gql_query!(Commit); -gql_query!(Issue); -gql_query!(PullRequest); -gql_query!(Repository); -gql_query!(IssueComments); -gql_query!(IssueID); -gql_query!(PullRequestComments); -gql_query!(PullRequestID); -gql_query!(CommitID); -gql_query!(CommitStatuses); -gql_query!(RepositoryID); -gql_query!(PullRequestReactions); -gql_query!(PullRequestCommentReactions); -// gql_query!(IssuesClosedByPullRequest); -gql_query!(LabelID); - -gql_query!(PostComment); -gql_query!(PostCheckRun); -gql_query!(ReactToPullRequestComment); -gql_query!(AddIssueLabels); +macro_rules! gql_query { + ($name:ident, $query_name:expr) => { + gql_query_base!($name); + + impl $name { + pub(crate) fn name() -> &'static str { + $query_name + } + } + }; +} + +macro_rules! gql_mutation { + ($name:ident, $query_name:expr) => { + gql_query_base!($name); + }; +} + +gql_query!(CurrentUser, "CurrentUser"); +gql_query!(Members, "Members"); +gql_query!(User, "User"); +gql_query!(Commit, "Commit"); +gql_query!(Issue, "Issue"); +gql_query!(PullRequest, "PullRequest"); +gql_query!(Repository, "Repository"); +gql_query!(IssueComments, "IssueComments"); +gql_query!(IssueID, "IssueID"); +gql_query!(PullRequestComments, "PullRequestComments"); +gql_query!(PullRequestID, "PullRequestID"); +gql_query!(CommitID, "CommitID"); +gql_query!(CommitStatuses, "CommitStatuses"); +gql_query!(RepositoryID, "RepositoryID"); +gql_query!(PullRequestReactions, "PullRequestReactions"); +gql_query!(PullRequestCommentReactions, "PullRequestCommentReactions"); +// gql_query!(IssuesClosedByPullRequest, "IssuesClosedByPullRequest"); +gql_query!(LabelID, "LabelID"); + +gql_mutation!(PostComment, "PostComment"); +gql_mutation!(PostCheckRun, "PostCheckRun"); +gql_mutation!(ReactToPullRequestComment, "ReactToPullRequestComment"); +gql_mutation!(AddIssueLabels, "AddIssueLabels"); pub(crate) struct RepoParentInfo<'a> { pub owner: &'a str, @@ -101,3 +120,94 @@ impl_repo_info!(commit::RepoInfo); impl_repo_info!(issue::RepoInfo); impl_repo_info!(pull_request::RepoInfo); impl_repo_info!(repository::RepoInfo); + +#[derive(Debug, Clone, Copy)] +pub(crate) struct RateLimitInfo { + pub cost: i64, + pub limit: i64, + pub remaining: i64, + pub reset_at: DateTime, +} + +impl RateLimitInfo { + pub(crate) fn inspect(&self, name: &str) { + let (level, msg) = match self.remaining { + 0 => ( + Level::Error, + format!( + "rate limit has been hit: {} used (resets at {})", + self.limit, + self.reset_at, + ), + ), + r if r <= 100 => ( + Level::Warn, + format!( + "rate limit is nearing: {} / {} left (resets at {})", + r, + self.limit, + self.reset_at, + ), + ), + r if r <= 1000 => ( + Level::Info, + format!( + "rate limit is approaching: {} / {} left (resets at {})", + r, + self.limit, + self.reset_at, + ), + ), + r => ( + Level::Debug, + format!( + "rate limit is OK: {} / {} left (resets at {})", + r, + self.limit, + self.reset_at, + ), + ), + }; + + log!(target: "github", level, "{}: {}", name, msg); + trace!( + target: "github", + "rate limit cost: {} / {}", + self.cost, + self.limit, + ); + } +} + +macro_rules! impl_into_rate_limit_info { + ($type:path) => { + impl From<$type> for RateLimitInfo { + fn from(info: $type) -> Self { + Self { + cost: info.cost, + limit: info.limit, + remaining: info.remaining, + reset_at: info.reset_at, + } + } + } + }; +} + +impl_into_rate_limit_info!(current_user::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(members::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(user::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(commit::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(issue::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(pull_request::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(repository::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(issue_comments::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(issue_id::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(pull_request_comments::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(pull_request_id::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(commit_id::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(commit_statuses::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(repository_id::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(pull_request_reactions::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(pull_request_comment_reactions::RateLimitInfoRateLimit); +impl_into_rate_limit_info!(label_id::RateLimitInfoRateLimit); -- GitLab From bf7680c6b941248ffc646e5a73df8559cc7e1355 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Tue, 25 Sep 2018 10:41:10 -0400 Subject: [PATCH 11/11] GithubService: allow access to the inner client Due to limitations in webhook information, more information may be required. Since GraphQL is flexible enough, just allow for arbitrary queries. --- ghostflow-github/src/client.rs | 2 +- ghostflow-github/src/ghostflow.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ghostflow-github/src/client.rs b/ghostflow-github/src/client.rs index fa4678c3..7f0e8fe4 100644 --- a/ghostflow-github/src/client.rs +++ b/ghostflow-github/src/client.rs @@ -262,7 +262,7 @@ impl Github { } /// Send a GraphQL query. - pub(crate) fn send<'de, Q>(&self, query: &QueryBody<Q::Variables>) -> Result<Q::ResponseData> + pub fn send<'de, Q>(&self, query: &QueryBody<Q::Variables>) -> Result<Q::ResponseData> where Q: GraphQLQuery<'de>, for<'d> Q::ResponseData: Deserialize<'d>, { diff --git a/ghostflow-github/src/ghostflow.rs b/ghostflow-github/src/ghostflow.rs index 52edc1d9..62173a59 100644 --- a/ghostflow-github/src/ghostflow.rs +++ b/ghostflow-github/src/ghostflow.rs @@ -280,7 +280,7 @@ impl GithubService { } /// Splits a project name in to an owner, name pair. - fn split_project(project: &str) -> Result<(&str, &str)> { + pub fn split_project(project: &str) -> Result<(&str, &str)> { let mut split = project.split('/'); if let Some(owner) = split.next() { if let Some(name) = split.next() { @@ -428,6 +428,11 @@ impl GithubService { { rate_limit.as_ref().map(|info| info.clone().into().inspect(name)); } + + /// Access the GitHub client. + pub fn github(&self) -> &Github { + &self.github + } } impl HostingService for GithubService { -- GitLab