### GraphQL Query Example Source: https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions An example GraphQL query to fetch discussions from a repository, including pagination information. ```APIDOC ```graphql query { repository(owner: "github", name: "some-repo") { discussions(first: 10) { # type: DiscussionConnection totalCount # Int! pageInfo { # type: PageInfo (from the public schema) startCursor endCursor hasNextPage hasPreviousPage } edges { # type: DiscussionEdge cursor node { # type: Discussion id } } nodes { # type: Discussion id } } } } ``` ``` -------------------------------- ### EnterpriseServerInstallationOrder Source: https://docs.github.com/en/graphql/reference/enterprise-admin Input object for specifying ordering options for Enterprise Server installation connections, including direction and field. ```APIDOC ## EnterpriseServerInstallationOrder - input object Ordering options for Enterprise Server installation connections. ### Input fields for `EnterpriseServerInstallationOrder` * `direction` (OrderDirection!): The ordering direction. * `field` (EnterpriseServerInstallationOrderField!): The field to order Enterprise Server installations by. ``` -------------------------------- ### StartRepositoryMigrationInput Source: https://docs.github.com/en/graphql/reference/migrations Defines the input parameters for starting a repository migration. This includes access tokens, repository URLs, owner IDs, and migration options. ```APIDOC ## StartRepositoryMigrationInput - input object Autogenerated input type of StartRepositoryMigration. ### Input fields for `StartRepositoryMigrationInput` * `accessToken` (String): The migration source access token. * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `continueOnError` (Boolean): Whether to continue the migration on error. Defaults to true. * `gitArchiveUrl` (String): The signed URL to access the user-uploaded git archive. * `githubPat` (String): The GitHub personal access token of the user importing to the target repository. * `lockSource` (Boolean): Whether to lock the source repository. * `metadataArchiveUrl` (String): The signed URL to access the user-uploaded metadata archive. * `ownerId` (ID!): The ID of the organization that will own the imported repository. * `repositoryName` (String!): The name of the imported repository. * `skipReleases` (Boolean): Whether to skip migrating releases for the repository. * `sourceId` (ID!): The ID of the migration source. * `sourceRepositoryUrl` (URI!): The URL of the source repository. * `targetRepoVisibility` (String): The visibility of the imported repository. ``` -------------------------------- ### StartOrganizationMigrationInput Source: https://docs.github.com/en/graphql/reference/migrations Defines the input parameters required to start an organization migration. This includes access tokens, URLs, and IDs for both source and target organizations. ```APIDOC ## StartOrganizationMigrationInput - input object Autogenerated input type of StartOrganizationMigration. ### Input fields for `StartOrganizationMigrationInput` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `sourceAccessToken` (String!): The migration source access token. * `sourceOrgUrl` (URI!): The URL of the organization to migrate. * `targetEnterpriseId` (ID!): The ID of the enterprise the target organization belongs to. * `targetOrgName` (String!): The name of the target organization. ``` -------------------------------- ### startRepositoryMigration Source: https://docs.github.com/en/graphql/reference/migrations Starts a GitHub Enterprise Importer (GEI) repository migration. This mutation takes an input object with details for migrating a single repository. ```APIDOC ## startRepositoryMigration - mutation Starts a GitHub Enterprise Importer (GEI) repository migration. ### Input fields for `startRepositoryMigration` * `input` (StartRepositoryMigrationInput!): ### Return fields for `startRepositoryMigration` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `repositoryMigration` (RepositoryMigration): The new repository migration. ``` -------------------------------- ### New File Addition Example Source: https://docs.github.com/en/graphql/reference/git Use this snippet to create a new file in the Git tree. Ensure the path is unique and contents are base64 encoded. ```json { "additions" [ { "path": "docs/README.txt", "contents": "base64encode(\"hello world\\n\")" } ] } ``` -------------------------------- ### EnterpriseServerInstallationMembershipEdge Source: https://docs.github.com/en/graphql/reference/enterprise-admin Represents an Enterprise Server installation that a user is a member of, including the cursor, node, and the user's role. ```APIDOC ## EnterpriseServerInstallationMembershipEdge - object An Enterprise Server installation that a user is a member of. ### Fields for `EnterpriseServerInstallationMembershipEdge` * `cursor` (String!): A cursor for use in pagination. * `node` (EnterpriseServerInstallation): The item at the end of the edge. * `role` (EnterpriseUserAccountMembershipRole!): The role of the user in the enterprise membership. ``` -------------------------------- ### startOrganizationMigration Source: https://docs.github.com/en/graphql/reference/migrations Starts a GitHub Enterprise Importer organization migration. This mutation requires an input object containing details about the source and target of the migration. ```APIDOC ## startOrganizationMigration - mutation Starts a GitHub Enterprise Importer organization migration. ### Input fields for `startOrganizationMigration` * `input` (StartOrganizationMigrationInput!): ### Return fields for `startOrganizationMigration` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `orgMigration` (OrganizationMigration): The new organization migration. ``` -------------------------------- ### GraphQL Schema Definition with Interface and Type Source: https://docs.github.com/en/graphql/guides/introduction-to-graphql This example demonstrates how to define a GraphQL interface and a type that implements it, showcasing inheritance and the use of '!' for required fields. ```graphql interface X { some_field: String! other_field: String! } type Y implements X { some_field: String! other_field: String! new_field: String! } ``` -------------------------------- ### EnterpriseServerInstallation Source: https://docs.github.com/en/graphql/reference/enterprise-admin Represents an Enterprise Server installation, including its creation and update times, customer name, host name, connection status, and related user accounts and uploads. ```APIDOC ## EnterpriseServerInstallation - object An Enterprise Server installation. **Implements:** Node ### Fields for `EnterpriseServerInstallation` * `createdAt` (DateTime!): Identifies the date and time when the object was created. * `customerName` (String!): The customer name to which the Enterprise Server installation belongs. * `hostName` (String!): The host name of the Enterprise Server installation. * `id` (ID!): The Node ID of the EnterpriseServerInstallation object. * `isConnected` (Boolean!): Whether or not the installation is connected to an Enterprise Server installation via GitHub Connect. * `updatedAt` (DateTime!): Identifies the date and time when the object was last updated. * `userAccounts` (EnterpriseServerUserAccountConnection!): User accounts on this Enterprise Server installation. * `after` (String): Returns the elements in the list that come after the specified cursor. * `before` (String): Returns the elements in the list that come before the specified cursor. * `first` (Int): Returns the first n elements from the list. * `last` (Int): Returns the last n elements from the list. * `orderBy` (EnterpriseServerUserAccountOrder): Ordering options for Enterprise Server user accounts returned from the connection. * `userAccountsUploads` (EnterpriseServerUserAccountsUploadConnection!): User accounts uploads for the Enterprise Server installation. * `after` (String): Returns the elements in the list that come after the specified cursor. * `before` (String): Returns the elements in the list that come before the specified cursor. * `first` (Int): Returns the first n elements from the list. * `last` (Int): Returns the last n elements from the list. * `orderBy` (EnterpriseServerUserAccountsUploadOrder): Ordering options for Enterprise Server user accounts uploads returned from the connection. ``` -------------------------------- ### File Rename with No Changes Example Source: https://docs.github.com/en/graphql/reference/git Rename a file by deleting it from the old path and adding it with the same content to the new path. Both paths must be unique. ```json { "deletions" [ { "path": "docs/README.txt" } ], "additions" [ { "path": "newdocs/README.txt", "contents": "base64encode(\"hello world\\n\")" } ] } ``` -------------------------------- ### GraphQL Mutation Response Example Source: https://docs.github.com/en/graphql/guides/forming-calls-with-graphql This is an example of a JSON response received after performing a GraphQL mutation. It shows the data returned by the server, including the 'reaction' and 'subject' fields. ```json { "data": { "addReaction": { "reaction": { "content": "HOORAY" }, "subject": { "id": "MDU6SXNzdWUyMTc5NTQ0OTc=" } } } } ``` -------------------------------- ### Existing File Modification Example Source: https://docs.github.com/en/graphql/reference/git Modify an existing file by providing its path and new base64 encoded contents. The path must already exist. ```json { "additions" [ { "path": "docs/README.txt", "contents": "base64encode(\"new content here\\n\")" } ] } ``` -------------------------------- ### EnterpriseServerInstallationConnection Source: https://docs.github.com/en/graphql/reference/enterprise-admin The connection type for EnterpriseServerInstallation, providing a list of edges, nodes, page information, and total count for paginating through enterprise server installations. ```APIDOC ## EnterpriseServerInstallationConnection - object The connection type for EnterpriseServerInstallation. ### Fields for `EnterpriseServerInstallationConnection` * `edges` ([EnterpriseServerInstallationEdge]): A list of edges. * `nodes` ([EnterpriseServerInstallation]): A list of nodes. * `pageInfo` (PageInfo!): Information to aid in pagination. * `totalCount` (Int!): Identifies the total count of items in the connection. ``` -------------------------------- ### EnterpriseServerInstallationOrderField Source: https://docs.github.com/en/graphql/reference/enterprise-admin Enum defining the properties by which Enterprise Server installation connections can be ordered. ```APIDOC ## EnterpriseServerInstallationOrderField - enum Properties by which Enterprise Server installation connections can be ordered. ``` -------------------------------- ### updateIpAllowListForInstalledAppsEnabledSetting Source: https://docs.github.com/en/graphql/reference/enterprise-admin Sets whether IP allow list configuration for installed GitHub Apps is enabled on an owner. ```APIDOC ## updateIpAllowListForInstalledAppsEnabledSetting - mutation ### Description Sets whether IP allow list configuration for installed GitHub Apps is enabled on an owner. ### Input fields for `UpdateIpAllowListForInstalledAppsEnabledSettingInput` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `ownerId` (ID!): The ID of the owner. * `settingValue` (IpAllowListForInstalledAppsEnabledSettingValue!): The value for the IP allow list configuration for installed GitHub Apps setting. ### Return fields for `updateIpAllowListForInstalledAppsEnabledSetting` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `owner` (IpAllowListOwner): The IP allow list owner on which the setting was updated. ``` -------------------------------- ### Existing File Deletion Example Source: https://docs.github.com/en/graphql/reference/git Use this snippet to remove an existing file from the Git tree. The specified path must exist. ```json { "deletions" [ { "path": "docs/README.txt" } ] } ``` -------------------------------- ### Calculate Total Nodes in a Simple GraphQL Query Source: https://docs.github.com/en/graphql/overview/resource-limitations This example demonstrates how to calculate the total number of nodes requested in a simple GraphQL query. It breaks down the calculation for repositories and their issues. ```graphql query { viewer { repositories(first: 50) { edges { repository:node { name issues(first: 10) { totalCount edges { node { title bodyHTML } } } } } } } } ``` ```text 50 = 50 repositories + 50 x 10 = 500 repository issues = 550 total nodes ``` -------------------------------- ### Request Previous Page of Pull Requests Source: https://docs.github.com/en/graphql/guides/using-pagination-in-the-graphql-api Fetch the previous page of pull requests using the 'startCursor' from a subsequent page as the 'before' argument. This example requests one item and assumes a 'last' argument was used initially. ```graphql query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { pullRequests(last: 1, before: "R3Vyc29yOnYyOpHOHcfoOg==") { nodes { createdAt number title } pageInfo { startCursor hasPreviousPage } } } } ``` -------------------------------- ### Estimate GraphQL Query Point Value Source: https://docs.github.com/en/graphql/overview/resource-limitations Use this example to understand how to calculate the point value of a GraphQL query before making the request. This helps in managing primary rate limits. ```graphql query { viewer { login repositories(first: 100) { edges { node { id issues(first: 50) { edges { node { id labels(first: 60) { edges { node { id name } } } } } } } } } } } ``` -------------------------------- ### File Rename with Content Changes Example Source: https://docs.github.com/en/graphql/reference/git Rename a file and modify its content simultaneously. Provide the old path for deletion and the new path with new base64 encoded contents for addition. ```json { "deletions" [ { "path": "docs/README.txt" } ], "additions" [ { "path": "newdocs/README.txt", "contents": "base64encode(\"new contents\\n\")" } ] } ``` -------------------------------- ### GraphQL Query and Mutation Example Source: https://docs.github.com/en/graphql/guides/forming-calls-with-graphql This snippet demonstrates a common pattern where a query is used to retrieve an issue ID, which is then used in a subsequent mutation to add an emoji reaction to that issue. It includes both the query to find the issue ID and the mutation to add the reaction. ```graphql query FindIssueID { repository(owner:"octocat", name:"Hello-World") { issue(number:349) { id } } } mutation AddReactionToIssue { addReaction(input:{subjectId:"MDU6SXNzdWUyMzEzOTE1NTE=",content:HOORAY}) { reaction { content } subject { id } } } ``` -------------------------------- ### EnterpriseServerUserAccount Source: https://docs.github.com/en/graphql/reference/enterprise-admin Represents a user account on an Enterprise Server installation. It includes details like creation date, associated emails, installation information, and user identifiers. ```APIDOC ## EnterpriseServerUserAccount - object A user account on an Enterprise Server installation. **Implements:** Node ### Fields for `EnterpriseServerUserAccount` * `createdAt` (DateTime!): Identifies the date and time when the object was created. * `emails` (EnterpriseServerUserAccountEmailConnection!): User emails belonging to this user account. * `after` (String): Returns the elements in the list that come after the specified cursor. * `before` (String): Returns the elements in the list that come before the specified cursor. * `first` (Int): Returns the first n elements from the list. * `last` (Int): Returns the last n elements from the list. * `orderBy` (EnterpriseServerUserAccountEmailOrder): Ordering options for Enterprise Server user account emails returned from the connection. * `enterpriseServerInstallation` (EnterpriseServerInstallation!): The Enterprise Server installation on which this user account exists. * `id` (ID!): The Node ID of the EnterpriseServerUserAccount object. * `isSiteAdmin` (Boolean!): Whether the user account is a site administrator on the Enterprise Server installation. * `login` (String!): The login of the user account on the Enterprise Server installation. * `profileName` (String): The profile name of the user account on the Enterprise Server installation. * `remoteCreatedAt` (DateTime!): The date and time when the user account was created on the Enterprise Server installation. * `remoteUserId` (Int!): The ID of the user account on the Enterprise Server installation. * `updatedAt` (DateTime!): Identifies the date and time when the object was last updated. ``` -------------------------------- ### Introspection Query via GET Request Source: https://docs.github.com/en/graphql/guides/introduction-to-graphql Perform an introspection query of the GraphQL schema using a GET request to the API endpoint. Ensure you include a valid authorization token. ```shell curl -H "Authorization: bearer TOKEN" https://api.github.com/graphql ``` -------------------------------- ### EnterpriseServerUserAccountsUpload Source: https://docs.github.com/en/graphql/reference/enterprise-admin Represents a user account upload from an Enterprise Server installation. It includes details about its creation, associated enterprise, the source Enterprise Server installation, its name, synchronization state, and update time. ```APIDOC ## EnterpriseServerUserAccountsUpload - object A user accounts upload from an Enterprise Server installation. **Implements:** Node ### Fields for `EnterpriseServerUserAccountsUpload` * `createdAt` (DateTime!): Identifies the date and time when the object was created. * `enterprise` (Enterprise!): The enterprise to which this upload belongs. * `enterpriseServerInstallation` (EnterpriseServerInstallation!): The Enterprise Server installation for which this upload was generated. * `id` (ID!): The Node ID of the EnterpriseServerUserAccountsUpload object. * `name` (String!): The name of the file uploaded. * `syncState` (EnterpriseServerUserAccountsUploadSyncState!): The synchronization state of the upload. * `updatedAt` (DateTime!): Identifies the date and time when the object was last updated. ``` -------------------------------- ### CheckAnnotationSpan Source: https://docs.github.com/en/graphql/reference/checks Represents an inclusive pair of positions (start and end) for a check annotation. ```APIDOC ## CheckAnnotationSpan - object An inclusive pair of positions for a check annotation. ### Fields for `CheckAnnotationSpan` * `end` (CheckAnnotationPosition!): End position (inclusive). * `start` (CheckAnnotationPosition!): Start position (inclusive). ``` -------------------------------- ### EnterpriseServerUserAccountEmail Source: https://docs.github.com/en/graphql/reference/enterprise-admin Represents an email address associated with a user account on an Enterprise Server installation. ```APIDOC ## EnterpriseServerUserAccountEmail - object An email belonging to a user account on an Enterprise Server installation. **Implements:** Node ### Fields for `EnterpriseServerUserAccountEmail` * `createdAt` (DateTime!): Identifies the date and time when the object was created. * `email` (String!): The email address. * `id` (ID!): The Node ID of the EnterpriseServerUserAccountEmail object. * `isPrimary` (Boolean!): Indicates whether this is the primary email of the associated user account. * `updatedAt` (DateTime!): Identifies the date and time when the object was last updated. * `userAccount` (EnterpriseServerUserAccount!): The user account to which the email belongs. ``` -------------------------------- ### createSponsorship Source: https://docs.github.com/en/graphql/reference/sponsors Starts a new sponsorship or reactivates a past sponsorship for a maintainer on GitHub Sponsors. ```APIDOC ## createSponsorship - mutation Start a new sponsorship of a maintainer in GitHub Sponsors, or reactivate a past sponsorship. ### Input fields for `createSponsorship` * `input` (CreateSponsorshipInput!): ### Return fields for `createSponsorship` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `sponsorship` (Sponsorship): The sponsorship that was started. ``` -------------------------------- ### createRepository Source: https://docs.github.com/en/graphql/reference/repos Creates a new repository with specified details. This mutation allows setting the name, description, visibility, and enabling features like issues and wiki. ```APIDOC ## createRepository - mutation Create a new repository. ### Input fields for `createRepository` * `input` (CreateRepositoryInput!): ### Return fields for `createRepository` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `repository` (Repository): The new repository. ``` -------------------------------- ### IpAllowListForInstalledAppsEnabledSettingValue Source: https://docs.github.com/en/graphql/reference/enterprise-admin Enum representing the possible values for the IP allow list configuration for installed GitHub Apps setting. ```APIDOC ## Enum: IpAllowListForInstalledAppsEnabledSettingValue ### Description The possible values for the IP allow list configuration for installed GitHub Apps setting. ### Values * `DISABLED`: The setting is disabled for the owner. * `ENABLED`: The setting is enabled for the owner. ``` -------------------------------- ### createEnvironment Source: https://docs.github.com/en/graphql/reference/deployments Creates an environment or returns it if it already exists. Requires a CreateEnvironmentInput object with the environment name and repository ID. ```APIDOC ## createEnvironment - mutation Creates an environment or simply returns it if already exists. ### Input fields for `createEnvironment` * `input` (CreateEnvironmentInput!): ### Return fields for `createEnvironment` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `environment` (Environment): The new or existing environment. ``` -------------------------------- ### createProjectV2 Source: https://docs.github.com/en/graphql/reference/projects Creates a new project with a specified title and owner. ```APIDOC ## createProjectV2 ### Description Creates a new project. You must provide the owner ID and title for the new project. Optionally, you can link it to a repository or team. ### Method MUTATION ### Endpoint /graphql ### Parameters #### Input arguments - **input** (CreateProjectV2Input!): Input object for the createProjectV2 mutation. ### Input Object: CreateProjectV2Input #### Input fields for `CreateProjectV2Input` - **clientMutationId** (String): A unique identifier for the client performing the mutation. - **ownerId** (ID!): The owner ID to create the project under. - **repositoryId** (ID): The repository to link the project to. - **teamId** (ID): The team to link the project to. The team will be granted read permissions. - **title** (String!): The title of the project. ### Return fields for `createProjectV2` - **clientMutationId** (String): A unique identifier for the client performing the mutation. - **projectV2** (ProjectV2): The new project. ``` -------------------------------- ### meta Query Source: https://docs.github.com/en/graphql/reference/meta Return information about the GitHub instance. Returns GitHubMetadata. ```APIDOC ## meta - query Return information about the GitHub instance. **Type:** GitHubMetadata! ``` -------------------------------- ### license Source: https://docs.github.com/en/graphql/reference/licenses Look up an open source license by its key. This query returns a License object. ```APIDOC ## license - query Look up an open source license by its key. **Type:** License ### Arguments for `license` * `key` (String!): The license's downcased SPDX ID. ``` -------------------------------- ### Defining a Variable in JSON Source: https://docs.github.com/en/graphql/guides/forming-calls-with-graphql Shows how to define a variable within a 'variables' object, which must be valid JSON. This example defines an integer variable. ```graphql variables { "number_of_repos": 3 } ``` -------------------------------- ### importProject Source: https://docs.github.com/en/graphql/reference/migrations Creates a new project by importing columns and a list of issues/PRs. Note: Projects (classic) is being deprecated. ```APIDOC ## importProject - mutation > [!WARNING] > **Deprecation notice:** Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC. ### Description Creates a new project by importing columns and a list of issues/PRs. ### Input fields for `importProject` * `input` (ImportProjectInput!): ### Return fields for `importProject` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `project` (Project): The new Project!. ``` -------------------------------- ### Deployment Source: https://docs.github.com/en/graphql/reference/deployments Represents a triggered deployment instance. It includes details about the commit, creator, description, environment, and status. ```APIDOC ## Deployment - object Represents triggered deployment instance. **Implements:** Node ### Fields for `Deployment` * `commit` (Commit): Identifies the commit sha of the deployment. * `commitOid` (String!): Identifies the oid of the deployment commit, even if the commit has been deleted. * `createdAt` (DateTime!): Identifies the date and time when the object was created. * `creator` (Actor!): Identifies the actor who triggered the deployment. * `databaseId` (Int): Identifies the primary key from the database. * `description` (String): The deployment description. * `environment` (String): The latest environment to which this deployment was made. * `id` (ID!): The Node ID of the Deployment object. * `latestEnvironment` (String): The latest environment to which this deployment was made. * `latestStatus` (DeploymentStatus): The latest status of this deployment. * `originalEnvironment` (String): The original environment to which this deployment was made. * `payload` (String): Extra information that a deployment system might need. * `ref` (Ref): Identifies the Ref of the deployment, if the deployment was created by ref. * `repository` (Repository!): Identifies the repository associated with the deployment. * `state` (DeploymentState): The current state of the deployment. * `statuses` (DeploymentStatusConnection): A list of statuses associated with the deployment. _(Pagination: `after`, `before`, `first`, `last`) * `task` (String): The deployment task. * `updatedAt` (DateTime!): Identifies the date and time when the object was last updated. ``` -------------------------------- ### GraphQL Query with a Single Variable Source: https://docs.github.com/en/graphql/guides/forming-calls-with-graphql An example of a GraphQL query that uses a single integer variable to dynamically set the number of repositories to fetch. ```graphql query($number_of_repos:Int!) { viewer { name repositories(last: $number_of_repos) { nodes { name } } } } variables { "number_of_repos": 3 } ``` -------------------------------- ### createProject Source: https://docs.github.com/en/graphql/reference/projects-classic Creates a new project. This mutation is part of the Projects (Classic) API and is subject to deprecation. ```APIDOC ## createProject - mutation Creates a new project. ### Input fields for `createProject` * `input` (CreateProjectInput!): ### Return fields for `createProject` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `project` (Project): The new project. ``` -------------------------------- ### licenses Source: https://docs.github.com/en/graphql/reference/licenses Return a list of known open source licenses. This query returns a list of License objects. ```APIDOC ## licenses - query Return a list of known open source licenses. **Type:** [License]! ``` -------------------------------- ### DeploymentReviewConnection Source: https://docs.github.com/en/graphql/reference/deployments Represents a connection to a list of deployment reviews, providing pagination details. ```APIDOC ## DeploymentReviewConnection ### Description The connection type for DeploymentReview. ### Fields * `edges` ([DeploymentReviewEdge]): A list of edges. * `nodes` ([DeploymentReview]): A list of nodes. * `pageInfo` (PageInfo!): Information to aid in pagination. * `totalCount` (Int!): Identifies the total count of items in the connection. ``` -------------------------------- ### EnterpriseServerInstallationEdge Source: https://docs.github.com/en/graphql/reference/enterprise-admin Represents an edge in a connection for EnterpriseServerInstallation, containing a cursor for pagination and the node itself. ```APIDOC ## EnterpriseServerInstallationEdge - object An edge in a connection. ### Fields for `EnterpriseServerInstallationEdge` * `cursor` (String!): A cursor for use in pagination. * `node` (EnterpriseServerInstallation): The item at the end of the edge. ``` -------------------------------- ### GraphQL Mutation with Incorrect Type Source: https://docs.github.com/en/graphql/guides/migrating-from-rest-to-graphql Example of a GraphQL mutation where 'clientMutationId' is mistakenly provided as an integer instead of a string. This demonstrates a common type error. ```graphql mutation { addComment(input:{clientMutationId: 1234, subjectId: "MDA6SXNzdWUyMjcyMDA2MTT=", body: "Looks good to me!"}) { clientMutationId commentEdge { node { body repository { id name nameWithOwner } issue { number } } } } } ``` -------------------------------- ### createSponsorsListing Source: https://docs.github.com/en/graphql/reference/sponsors Creates a GitHub Sponsors profile, allowing others to sponsor you or your organization. This mutation requires a `CreateSponsorsListingInput` object. ```APIDOC ## createSponsorsListing - mutation Create a GitHub Sponsors profile to allow others to sponsor you or your organization. ### Input fields for `createSponsorsListing` * `input` (CreateSponsorsListingInput!): ### Return fields for `createSponsorsListing` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `sponsorsListing` (SponsorsListing): The new GitHub Sponsors profile. ``` -------------------------------- ### EnterpriseUserAccount Fields Source: https://docs.github.com/en/graphql/reference/enterprise-admin Provides details about the fields available for an EnterpriseUserAccount, including its avatar, creation date, associated enterprise, installations, organizations, and user information. ```APIDOC ## EnterpriseUserAccount - object An account for a user who is an admin of an enterprise or a member of an enterprise through one or more organizations. **Implements:** Actor, Node ### Fields for `EnterpriseUserAccount` * `avatarUrl` (URI!): A URL pointing to the enterprise user account's public avatar. * `size` (Int): The size of the resulting square image. * `createdAt` (DateTime!): Identifies the date and time when the object was created. * `enterprise` (Enterprise!): The enterprise in which this user account exists. * `enterpriseInstallations` (EnterpriseServerInstallationMembershipConnection!): A list of Enterprise Server installations this user is a member of. * `after` (String): Returns the elements in the list that come after the specified cursor. * `before` (String): Returns the elements in the list that come before the specified cursor. * `first` (Int): Returns the first n elements from the list. * `last` (Int): Returns the last n elements from the list. * `orderBy` (EnterpriseServerInstallationOrder): Ordering options for installations returned from the connection. * `query` (String): The search string to look for. * `role` (EnterpriseUserAccountMembershipRole): The role of the user in the installation. * `id` (ID!): The Node ID of the EnterpriseUserAccount object. * `login` (String!): An identifier for the enterprise user account, a login or email address. * `name` (String): The name of the enterprise user account. * `organizations` (EnterpriseOrganizationMembershipConnection!): A list of enterprise organizations this user is a member of. * `after` (String): Returns the elements in the list that come after the specified cursor. * `before` (String): Returns the elements in the list that come before the specified cursor. * `first` (Int): Returns the first n elements from the list. * `last` (Int): Returns the last n elements from the list. * `orderBy` (OrganizationOrder): Ordering options for organizations returned from the connection. * `query` (String): The search string to look for. * `role` (EnterpriseUserAccountMembershipRole): The role of the user in the enterprise organization. * `resourcePath` (URI!): The HTTP path for this user. * `updatedAt` (DateTime!): Identifies the date and time when the object was last updated. * `url` (URI!): The HTTP URL for this user. * `user` (User): The user within the enterprise. ``` -------------------------------- ### DeploymentReview Source: https://docs.github.com/en/graphql/reference/deployments Represents a deployment review, including comments, state, and associated environments. ```APIDOC ## DeploymentReview ### Description A deployment review. ### Implements Node ### Fields * `comment` (String!): The comment the user left. * `databaseId` (Int): Identifies the primary key from the database. * `environments` (EnvironmentConnection!): The environments approved or rejected. _(Pagination: `after`, `before`, `first`, `last`) * `id` (ID!): The Node ID of the DeploymentReview object. * `state` (DeploymentReviewState!): The decision of the user. * `user` (User!): The user that reviewed the deployment. ``` -------------------------------- ### Query Specific Type Details Source: https://docs.github.com/en/graphql/guides/introduction-to-graphql Use the `__type` query to get detailed information about a specific type within the schema, such as its name, kind, description, and fields. ```graphql query { __type(name: "Repository") { name kind description fields { name } } } ``` -------------------------------- ### createLabel Source: https://docs.github.com/en/graphql/reference/issues Creates a new label within a repository. This mutation requires a name, color, and repository ID, and optionally accepts a description. ```APIDOC ## createLabel - mutation Creates a new label. ### Input fields for `createLabel` * `input` (CreateLabelInput!): ### Return fields for `createLabel` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `label` (Label): The new label. ``` -------------------------------- ### Create Discussion Mutation Source: https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions Example of how to create a new discussion within a repository using the GraphQL API. Requires repository ID, category ID, title, and body. ```graphql mutation { # input type: CreateDiscussionInput createDiscussion(input: {repositoryId: "1234", categoryId: "5678", body: "The body", title: "The title"}) { # response type: CreateDiscussionPayload discussion { id } } } ``` -------------------------------- ### GraphQL Mutation with Variables Source: https://docs.github.com/en/graphql/guides/forming-calls-with-graphql This example demonstrates how to rewrite a GraphQL mutation to use variables, which can make the syntax less unwieldy. The 'variables' block must be valid JSON. ```graphql mutation($myVar:AddReactionInput!) { addReaction(input:$myVar) { reaction { content } subject { id } } } variables { "myVar": { "subjectId":"MDU6SXNzdWUyMTc5NTQ0OTc=", "content":"HOORAY" } } ``` -------------------------------- ### createDeployment Source: https://docs.github.com/en/graphql/reference/deployments Creates a new deployment event. Accepts a CreateDeploymentInput object with details such as ref ID, repository ID, description, and environment. ```APIDOC ## createDeployment - mutation Creates a new deployment event. ### Input fields for `createDeployment` * `input` (CreateDeploymentInput!): ### Return fields for `createDeployment` * `autoMerged` (Boolean): True if the default branch has been auto-merged into the deployment ref. * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `deployment` (Deployment): The new deployment. ``` -------------------------------- ### linkProjectV2ToRepository Source: https://docs.github.com/en/graphql/reference/projects Links a project to a repository. ```APIDOC ## linkProjectV2ToRepository ### Description Links a project to a repository. ### Input fields for `linkProjectV2ToRepository` * `input` (LinkProjectV2ToRepositoryInput!): ### Return fields for `linkProjectV2ToRepository` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `repository` (Repository): The repository the project is linked to. ### Input fields for `LinkProjectV2ToRepositoryInput` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `projectId` (ID!): The ID of the project to link to the repository. * `repositoryId` (ID!): The ID of the repository to link to the project. ``` -------------------------------- ### Introspection Query in IDL Format Source: https://docs.github.com/en/graphql/guides/introduction-to-graphql Retrieve the GraphQL schema in IDL format by passing the `Accept: application/vnd.github.v4.idl` header with your GET request. This provides a condensed schema representation. ```shell $ curl -H "Authorization: bearer TOKEN" -H "Accept: application/vnd.github.v4.idl" \ https://api.github.com/graphql ``` -------------------------------- ### addProjectV2ItemById Source: https://docs.github.com/en/graphql/reference/projects Links an existing content instance (Issue or Pull Request) to a Project. This mutation requires the content ID and the project ID to associate the item. ```APIDOC ## addProjectV2ItemById - mutation Links an existing content instance to a Project. ### Input fields for `addProjectV2ItemById` * `input` (AddProjectV2ItemByIdInput!): ### Return fields for `addProjectV2ItemById` * `clientMutationId` (String): A unique identifier for the client performing the mutation. * `item` (ProjectV2Item): The item added to the project. ``` -------------------------------- ### ExternalIdentity Fields Source: https://docs.github.com/en/graphql/reference/enterprise-admin Details about an external identity provisioned by SAML SSO or SCIM, including its GUID, associated organization invitation, SAML attributes, SCIM attributes, and linked user. ```APIDOC ## ExternalIdentity - object An external identity provisioned by SAML SSO or SCIM. If SAML is configured on the organization, the external identity is visible to (1) organization owners, (2) organization owners' personal access tokens (classic) with read:org or admin:org scope, (3) GitHub App with an installation token with read or write access to members. If SAML is configured on the enterprise, the external identity is visible to (1) enterprise owners, (2) enterprise owners' personal access tokens (classic) with read:enterprise or admin:enterprise scope. **Implements:** Node ### Fields for `ExternalIdentity` * `guid` (String!): The GUID for this identity. * `id` (ID!): The Node ID of the ExternalIdentity object. * `organizationInvitation` (OrganizationInvitation): Organization invitation for this SCIM-provisioned external identity. * `samlIdentity` (ExternalIdentitySamlAttributes): SAML Identity attributes. * `scimIdentity` (ExternalIdentityScimAttributes): SCIM Identity attributes. * `user` (User): User linked to this external identity. Will be NULL if this identity has not been claimed by an organization member. ``` -------------------------------- ### Run a GraphQL query via GitHub CLI Source: https://docs.github.com/en/graphql/guides/using-graphql-clients Execute a GraphQL query directly from the command line using the gh api subcommand. ```shell gh api graphql -f query='query { viewer { login } }' ``` -------------------------------- ### Request Initial Page of Pull Requests Source: https://docs.github.com/en/graphql/guides/using-pagination-in-the-graphql-api Query for the first page of pull requests, requesting up to 100 items. Use 'after: null' for the initial request. The 'pageInfo' object provides cursors and navigation booleans for subsequent requests. ```graphql query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { pullRequests(first: 100, after: null) { nodes { createdAt number title } pageInfo { endCursor startCursor hasNextPage hasPreviousPage } } } } ``` -------------------------------- ### Request Next Page of Pull Requests Source: https://docs.github.com/en/graphql/guides/using-pagination-in-the-graphql-api Fetch the next page of pull requests by using the 'endCursor' from the previous response as the 'after' argument. This example requests only one item to demonstrate cursor usage. ```graphql query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { pullRequests(first: 1, after: "Y3Vyc29yOnYyOpHOUH8B7g==") { nodes { createdAt number title } pageInfo { endCursor hasNextPage hasPreviousPage } } } } ```