> For the complete documentation index, see [llms.txt](https://docs.graphlit.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphlit.dev/api-guides/use-cases/feeds/project-management/feed-create-github-pull-requests.md).

# 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)

```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

1. Developer Portal → Connectors → GitHub
2. Complete OAuth flow with required scopes (`repo` for private repos, public repo access for public repos)
3. Store the resulting credential; note the `authorizationId`
4. Use `queryGitHubRepositories` to 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**:

```typescript
repositoryOwner: 'your-org',
repositoryName: 'backend-api',
readLimit: 200  // Track last 200 PRs
```

**PR Workflow Analysis**:

```typescript
repositoryOwner: 'facebook',
repositoryName: 'react',
readLimit: 500
```

**Merge Velocity Monitoring**:

```typescript
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 number
* `title`: PR title
* `project`: Repository name
* `team`: Repository owner
* `status`: PR state (open/closed/merged)
* `type`: PR type (if specified)
* `baseBranch`: Target branch
* `headBranch`: Source branch
* `isDraft`: Whether PR is a draft
* `isMergeable`: Whether PR can be merged
* `mergeCommitSha`: SHA of merge commit (if merged)
* `mergedAt`: Timestamp when merged
* `filesChanged`: Number of files modified
* `additions`: Lines added
* `deletions`: Lines deleted
* `labels`: Associated labels

***

## Filtering and Search

Once synced, you can search and filter pull requests:

**Search by status**:

```typescript
const openPRs = await graphlit.queryContents({
  
    types: [ContentTypes.PullRequest],
    contents: [{
      pullRequest: {
        status: 'open'
      }
    }]
  });
```

**Search by branch**:

```typescript
const mainPRs = await graphlit.queryContents({
  
    types: [ContentTypes.PullRequest],
    contents: [{
      pullRequest: {
        baseBranch: 'main'
      }
    }]
  });
```

***

## Related

* [GitHub Commits Feed](/api-guides/use-cases/feeds/project-management/feed-create-github-commits.md) - Sync repository commits
* [GitHub Issues Feed](/api-guides/use-cases/feeds/project-management/feed-create-github-issues.md) - Sync repository issues
* [GitHub Repository Feed](/api-guides/use-cases/feeds/cloud-storage/feed-create-github.md) - Sync repo files
