Create GitHub Pull Requests Feed
User Intent
"How do I sync GitHub pull requests from a repository? Show me GitHub Pull Requests feed configuration."
Operation
SDK Method: createFeed() with FeedTypes.PullRequest
Auth: GitHub personal access token or OAuth
Code Example (TypeScript)
import { Graphlit } from 'graphlit-client';
import {
FeedTypes,
FeedServiceTypes,
GitHubPullRequestsFeedPropertiesInput,
GitHubPullRequestAuthenticationTypes,
GitHubRepositoriesInput,
} from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Use the GitHub credential stored in the Developer Portal
const authorizationId = process.env.GRAPHLIT_GITHUB_AUTH_ID!;
const repositoriesInput: GitHubRepositoriesInput = {
authenticationType: GitHubPullRequestAuthenticationTypes.OAuth,
authorizationId,
};
// Enumerate repositories this credential can access
const repositoriesResponse = await graphlit.queryGitHubRepositories(repositoriesInput);
const repositories = repositoriesResponse.githubRepositories?.results ?? [];
if (repositories.length === 0) {
throw new Error('No GitHub repositories available for the authorized account');
}
const { repositoryOwner, repositoryName } = repositories[0]!;
console.log(`Using GitHub repository: ${repositoryOwner}/${repositoryName}`);
const feed = await graphlit.createFeed({
name: 'Backend API Pull Requests',
type: FeedTypes.PullRequest,
pullRequest: {
type: FeedServiceTypes.GitHubPullRequests,
github: {
authorizationId,
authenticationType: GitHubPullRequestAuthenticationTypes.OAuth,
repositoryOwner: repositoryOwner!,
repositoryName: repositoryName!,
readLimit: 100,
},
},
// Optional: add workflow for content processing
// workflow: { id: workflow.createWorkflow.id }
});
console.log(`Created GitHub Pull Requests feed: ${feed.createFeed.id}`);Configuration
repositoryOwner: GitHub username or organization
repositoryName: Repository name
authorizationId: Stored GitHub credential identifier (OAuth recommended)
authenticationType: GitHubPullRequestAuthenticationTypes.OAuth or GitHubPullRequestAuthenticationTypes.PersonalAccessToken
readLimit: Number of pull requests to sync (defaults to 100)
GitHub Token Setup
Developer Portal → Connectors → GitHub
Complete OAuth flow with required scopes (
repofor private repos, public repo access for public repos)Store the resulting credential; note the
authorizationIdUse
queryGitHubRepositoriesto confirm repository access before creating feeds
What Gets Synced
Pull request numbers and titles
PR descriptions and bodies
Status (open/closed/merged)
Base and head branches
Draft status
Merge status and commit SHA
Merge timestamps
File change statistics (files changed, additions, deletions)
Labels and tags
Reviewer information
Author information
Use Cases
Code Review Tracking:
repositoryOwner: 'your-org',
repositoryName: 'backend-api',
readLimit: 200 // Track last 200 PRsPR Workflow Analysis:
repositoryOwner: 'facebook',
repositoryName: 'react',
readLimit: 500Merge Velocity Monitoring:
repositoryOwner: 'company',
repositoryName: 'product-repo'OAuth vs Personal Access Token
Use OAuth when:
Building multi-user applications
Need user-specific permissions
Want connector-based auth with automatic token refresh
Use Personal Access Token when:
Single-user automation
Service account access
Simpler setup for personal projects
Metadata Structure
Each synced pull request creates content with PullRequestMetadata:
identifier: PR numbertitle: PR titleproject: Repository nameteam: Repository ownerstatus: PR state (open/closed/merged)type: PR type (if specified)baseBranch: Target branchheadBranch: Source branchisDraft: Whether PR is a draftisMergeable: Whether PR can be mergedmergeCommitSha: SHA of merge commit (if merged)mergedAt: Timestamp when mergedfilesChanged: Number of files modifiedadditions: Lines addeddeletions: Lines deletedlabels: Associated labels
Filtering and Search
Once synced, you can search and filter pull requests:
Search by status:
const openPRs = await graphlit.queryContents({
filter: {
types: [ContentTypes.PullRequest],
contents: [{
pullRequest: {
status: 'open'
}
}]
}
});Search by branch:
const mainPRs = await graphlit.queryContents({
filter: {
types: [ContentTypes.PullRequest],
contents: [{
pullRequest: {
baseBranch: 'main'
}
}]
}
});Related
GitHub Commits Feed - Sync repository commits
GitHub Issues Feed - Sync repository issues
GitHub Repository Feed - Sync repo files
Last updated
Was this helpful?