Skip to content

Commit 2ffe743

Browse files
refactor(github): batched pull request reads use effect/graphql
The four aliased batch reads (summaries, watch fingerprints, line counts and stack memberships) were hand-built query strings with hand-written decoders. They are now generated from pullRequestBatches.graphql against GitHub's schema and batched by GraphQLResolver.aliased, sent through GitHubApi so quota, pause and credential handling are unchanged. A pull request GitHub cannot find now fails only its own lookup, as not found. Before, one missing pull request failed the whole batch, and every entry was read again on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cb65643 commit 2ffe743

19 files changed

Lines changed: 76417 additions & 800 deletions

‎.gitattributes‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
# Batch files need CRLF for cmd.exe to parse them reliably.
44
*.cmd text eol=crlf
55
*.bat text eol=crlf
6+
# GitHub's GraphQL schema and the operations graphqlgen writes from it.
7+
packages/source-control-github/schema/** linguist-generated
8+
**/*.graphql.ts linguist-generated

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ jobs:
5252
- name: Check unused code
5353
run: vp run knip:check
5454

55+
- name: Check generated GitHub GraphQL operations
56+
run: vp run --filter @t3tools/source-control-github generate --check
57+
5558
- name: Check
5659
run: vp check
5760

‎knip.jsonc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,10 @@
110110
"entry": ["test/fixtures/*.ts"],
111111
"ignoreIssues": { "src/_generated/**": ["exports", "types"] },
112112
},
113+
"packages/source-control-github": {
114+
// graphqlgen reads its config; the generated operations export every selection's class.
115+
"entry": ["graphql.config.ts"],
116+
"ignoreIssues": { "**/*.graphql.ts": ["exports", "types", "namespaceMembers"] },
117+
},
113118
},
114119
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "@effect/graphql-generator/Config";
2+
3+
// `schema/github.graphql` is github.com's public schema
4+
// (https://docs.github.com/public/fpt/schema.docs.graphql). Enterprise Server lacks some of its
5+
// fields, such as pull request stacks, so a document asks for those under `@include`.
6+
export default defineConfig({
7+
schema: "./schema/github.graphql",
8+
documents: ["src/**/*.graphql"],
9+
scalars: {
10+
GitObjectID: "effect/Schema#String",
11+
// Kept as GitHub sends it: callers compare these strings with other reads of the same field.
12+
DateTime: "effect/Schema#String",
13+
},
14+
});

‎packages/source-control-github/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
},
7575
"scripts": {
7676
"typecheck": "tsc-rs --noEmit",
77-
"test": "vp test run --config ../../vite.config.ts --dir ."
77+
"test": "vp test run --config ../../vite.config.ts --dir .",
78+
"generate": "graphqlgen"
7879
},
7980
"dependencies": {
8081
"@t3tools/contracts": "workspace:*",
@@ -84,6 +85,7 @@
8485
"effect": "catalog:"
8586
},
8687
"devDependencies": {
88+
"@effect/graphql-generator": "catalog:",
8789
"@effect/platform-node": "catalog:",
8890
"@effect/vitest": "catalog:",
8991
"@t3tools/source-control-testing": "workspace:*",

0 commit comments

Comments
 (0)