Skip to main content
Glama
queries.ts8.9 kB
/** * GraphQL queries for GitHub API */ export const QUERIES = { /** * Query to fetch authored pull requests using search API with date filtering * Uses GitHub search syntax: is:pr created:YYYY-MM-DD..YYYY-MM-DD author:username */ /** * Step 1: Get PR IDs from search * According to GitHub GraphQL API docs (https://docs.github.com/en/graphql/reference/queries#search): * - When type: ISSUE, nodes are SearchResultItem union (Issue | PullRequest) * - All nodes being null usually indicates permission issues or fragment mismatch * - Since we search with "is:pr", all results should be PullRequest type * - Query structure: Use PullRequest fragment first, include Issue fragment as fallback * - Note: Ensure token has 'repo' and 'read:org' scopes for private/org repositories */ AUTHoredPRsSearch: ` query AuthoredPRsSearch($searchQuery: String!, $after: String) { search(query: $searchQuery, type: ISSUE, first: 100, after: $after) { issueCount pageInfo { hasNextPage endCursor } nodes { __typename ... on PullRequest { id number url repository { nameWithOwner } } ... on Issue { id number url repository { nameWithOwner } } } } } `, /** * Step 2: Fetch full PR details by ID (this works reliably) */ AUTHoredPRsDetails: ` query AuthoredPRsDetails($prIds: [ID!]!) { nodes(ids: $prIds) { ... on PullRequest { id number title state createdAt mergedAt closedAt url repository { nameWithOwner } files(first: 100) { totalCount } additions deletions changedFiles } } } `, /** * Query to fetch PR reviews by a user */ PRReviews: ` query PRReviews($username: String!, $from: DateTime!, $to: DateTime!, $after: String) { user(login: $username) { contributionsCollection(from: $from, to: $to) { pullRequestReviewContributions(first: 100, after: $after) { pageInfo { hasNextPage endCursor } nodes { pullRequestReview { id state submittedAt pullRequest { id number title repository { nameWithOwner } } } } } } } } `, /** * Query to fetch review comments by a user */ ReviewComments: ` query ReviewComments($username: String!, $from: DateTime!, $to: DateTime!, $after: String) { user(login: $username) { contributionsCollection(from: $from, to: $to) { pullRequestReviewContributions(first: 100, after: $after) { pageInfo { hasNextPage endCursor } nodes { pullRequestReview { id state submittedAt body comments(first: 100) { totalCount nodes { id body path line createdAt } } pullRequest { id number title url createdAt repository { nameWithOwner } } } } } } } } `, /** * Query to fetch PR details including commits and file changes */ PRDetails: ` query PRDetails($prIds: [ID!]!) { nodes(ids: $prIds) { ... on PullRequest { id number title state createdAt mergedAt repository { nameWithOwner } files(first: 100) { totalCount nodes { path additions deletions changeType } } additions deletions changedFiles commits(first: 100) { totalCount nodes { commit { authoredDate message additions deletions changedFiles } } } } } } `, /** * Query to fetch PR timeline for comment impact analysis * * Note: PullRequestTimelineItemsItemType enum values: * - PULL_REQUEST_COMMIT * - PULL_REQUEST_REVIEW * - ISSUE_COMMENT (not PULL_REQUEST_COMMENT) */ PRTimeline: ` query PRTimeline($prId: ID!) { node(id: $prId) { ... on PullRequest { id commits(first: 100) { nodes { commit { id authoredDate committedDate message additions deletions changedFiles } } } timelineItems(first: 100, itemTypes: [PULL_REQUEST_REVIEW, ISSUE_COMMENT]) { nodes { ... on PullRequestReview { id state submittedAt body author { login } comments(first: 100) { nodes { id body path line createdAt } } } ... on IssueComment { id body createdAt author { login } } } } } } } `, /** * Query to fetch PR review comments by repository * Fetches PRs, then reviews, then review comments * Filters by comment.createdAt client-side */ PRReviewCommentsByRepo: ` query PRReviewCommentsByRepo($owner: String!, $repo: String!, $cursor: String) { repository(owner: $owner, name: $repo) { pullRequests(first: 50, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { number id title repository { nameWithOwner } reviews(first: 20) { nodes { id author { login } submittedAt comments(first: 50) { nodes { id body createdAt author { login } path line } } } } } } } } `, /** * Query to fetch PR issue comments by repository * Fetches PRs, then issue comments * Filters by comment.createdAt client-side */ PRIssueCommentsByRepo: ` query PRIssueCommentsByRepo($owner: String!, $repo: String!, $cursor: String) { repository(owner: $owner, name: $repo) { pullRequests(first: 50, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { number id title repository { nameWithOwner } comments(first: 50) { nodes { id author { login } body createdAt } } } } } } `, /** * Query to fetch PR issue comments by PR IDs (optimized) * Fetches specific PRs by ID, then their issue comments */ PRIssueCommentsByPRIds: ` query PRIssueCommentsByPRIds($prIds: [ID!]!) { nodes(ids: $prIds) { ... on PullRequest { number id title repository { nameWithOwner } comments(first: 100) { nodes { id author { login } body createdAt } } } } } `, };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/radireddy/github-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server