Pull Request Data Fetcher (pull-requests/fetchers.ts)

giselle · integration, Integration / API, github, pull-request, fetch, diff, api

Fetches pull‑request metadata, details, and file diffs from GitHub using Octokit and GraphQL, returning structured maps for further analysis.

// Source: https://github.com/mperkins0155/giselle | License: Apache-2.0 | Copyright 2024 ROUTE06, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type { Octokit } from "@octokit/core";
import type { Client } from "urql";
import { executeRestRequest } from "../utils";
import type { Comment, FileMetadata, PullRequestDetails } from "./cache";
import {
	GetPullRequestDetailsQuery,
	GetPullRequestsMetadataQuery,
} from "./queries";

export type FetchContext = {
	client: Client;
	owner: string;
	repo: string;
};

export type DiffFetchContext = {
	octokit: Octokit;
	owner: string;
	repo: string;
};

export async function fetchDiffs(
	ctx: DiffFetchContext,
	prNumber: number,
): Promise<Map<string, string>> {
	const fileDiffs = new Map<string, string>();
	let page = 1;

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key