Repository navigation
Generate the GitHub template from GitHub's GraphQL schema - #321
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 55f76aa | Nov 23 2026, 10:17 AM |
2f615f4 to
44d4514
Compare
44d4514 to
a242796
Compare
| "approval-methods.ts", | ||
| "input.ts", | ||
| ...(rules.kind === "discovery" ? ["google.ts"] : []), | ||
| rules.kind === "discovery" ? "google.ts" : "graphql.ts", |
There was a problem hiding this comment.
Regenerating an existing Linear app now replaces src/graphql.ts with a file that no longer exports linearApi or linearErrors. The app's existing src/connection.ts imports both, but this command does not update that file. The documented update command therefore leaves the app unable to build.
Keep the old exports compatible, or migrate the app's callers when replacing the shared builder. Its existing src/run.ts also needs the new result-name restoration when fragment fields become aliased.
There was a problem hiding this comment.
Intended: an app copied from the earlier Linear template, before the shared runtime existed, takes src/connection.ts and src/run.ts from the template once when it first regenerates. The generator owns only the files it writes and copies. Keeping linearApi/linearErrors exports in the shared builder would put Linear-specific code into every GraphQL template.
There was a problem hiding this comment.
Got it — that makes sense. The generator's responsibility is scoped to the files it generates, and apps migrating from the old Linear template should pick up the updated connection.ts and run.ts from the template itself during regeneration.
Is there documentation or a migration note that tells users to copy those files when regenerating, or is that expected to be obvious from the template structure? If users might miss it and end up with the broken imports, a note in the template README or regeneration docs could help.
Shall I remember this as a rule: "Template regeneration only updates generated files; apps migrating from earlier templates must manually copy connection.ts and run.ts from the template to avoid import breakage"?
87af02e to
0ea8549
Compare
0ea8549 to
8718586
Compare
11e4400 to
17cb5d5
Compare
The GitHub template wrapped three hand-written REST methods. It now offers GitHub's GraphQL API as typed methods with field selections, generated like the Linear template: pnpm --filter @platform/template-generator generate github. Mutations ask for approval by each user's level. Enterprise and organization administration, migrations, GitHub Sponsors and the mutations only GitHub Apps can call are not offered. The connector requests the scopes the offered methods need, and accounts connected with fewer scopes are asked to reconnect. The GraphQL request builder moves into the generator's shared runtime. The generator imports the template's environment type under its own name, since GitHub has a type called Environment, and stops when an API type would shadow another import.
GitHub's and Linear's responses larger than 8 MiB return too_large instead of being read into memory. addPullRequestReview asks first, since an event submits the review at once. The generator imports the JSON types that only method signatures use, and the catalog search test looks for a phrase of GitHub's new description.
Two variants of a union or interface may have a field of one name with different types, such as Issue.state and PullRequest.state. GraphQL rejects both in one selection under the same name. Fields inside ... on Variant now take the alias field__on__Variant, and results get their selected names back.
Restoring renamed every key ending in __on__Variant, including keys inside JSON values such as Linear's attachment metadata, and a field selected both for every type and in a fragment kept only one of its objects. The result is now read along the selection and the schema: only aliases the request wrote are renamed, both objects of one field are merged, and JSON values stay as the provider returned them.
A field selected for every type and in $on lands in one object of the result, so both selections must pass the same $args; requests that differ now fail before anything is sent. Selections may leave optional values undefined, as arguments already could.
Arguments of a field selected for every type and in $on are equal when they hold the same values, whatever order their keys have.
17cb5d5 to
55f76aa
Compare
|
@greptileai review |
Why
The GitHub template offers three hand-written REST methods: list repositories, list issues, read a file. Anything else, like opening issues or pull requests, reviews, discussions or projects, needs a template change. GitHub publishes its GraphQL schema, so the template can offer the whole API as typed methods, the same way the Linear template does.
What changes
GitHub template
Methods: 202 typed methods, 24 queries and 178 mutations, from GitHub's public GraphQL schema. Most data is reached through
repository,viewer,organization,nodeandsearch.Field selections: work like in Linear, including
$argsand$onfor interfaces and unions. Text files are read throughrepository.objectwith$on: { Blob: { text: true } }.Not offered (98 operations): listed in
scripts/operations.tswith a reason for each:admin:orgorwrite:org;Deprecated operations, such as classic Projects, are left out automatically.
Approvals: per-user approval level, like in Linear.
createis used only for pure additions: issues, comments, branches, reactions.addPullRequestReviewisupdate: given an event such asAPPROVE, it submits the review at once.updateRefs.Scopes:
repo,workflow,project,read:organduser.permission_requiredfrom every method and fromconnectionStatus, with a link to reconnect.Errors:
github_errorwith GitHub'stype, e.g.NOT_FOUNDRATE_LIMITEDerrors, exhausted or secondary rate limits (403/429)rate_limited, withretryAfterfromRetry-Afteror the limit's reset timereconnect_requiredaccess_deniedLarge responses: larger than 8 MiB give
too_large, in GitHub and Linear alike, instead of being read into memory.Removed: the REST methods and their helpers (
listRepositories,listIssues,readFile).template.mddescribes scopes, selections, approvals, results and how to regenerate.Generator and the other templates
extensions, GitHub readstype.... on Variantare aliased and restored along the selection, because two variants may have a field of one name with different types. A field selected both for every type and in$onmust pass the same$args. Selections may leave optional valuesundefined.Environmentimport: generated files import the template'sEnvironmentasTemplateEnvironment, because GitHub has a type calledEnvironment. The generator stops when an API type would shadow another import.access_denied; other statuses fail.Approval level form
A consuming app could send the approval level form through
env.GITHUB.fetch()with a forgedOrigin. #323 fixes that in the runtime for every template.Managed OAuth
A managed
githubclient only grants the scopes itsscopessetting allows. Installations that offer managed OAuth for GitHub must addworkflow,project,read:organduserto that setting. Until they do, starting a managed connection fails with "The requested scopes are not allowed for this client". Installations with their own OAuth app (GITHUB_CLIENT_ID/GITHUB_CLIENT_SECRET) aren't affected.Connection page
Connected state, with the same approval form as Linear and Gmail.
Not shown: the disconnected and setup-required states. They only change their description text.
Testing
pnpm checkTemplateEnvironmentalias.$onnarrows by__typename, and the README example compiles.

Confidence Score: 5/5 
No new blocking issue was found in this PR.Summary
Replaces GitHub’s three REST methods with 202 generated, typed GraphQL methods.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Typed method and field selection] --> B[Build GraphQL request] B --> C{Mutation needs approval?} C -->|Yes| D[Ask the current user] D -->|Accepted| E[Check connection and scopes] C -->|No| E E --> F[Call GitHub] F --> G[Limit response size and read errors] G --> H[Restore selected field names] H --> I[Return typed result]Reviews (10) · Last reviewed commit: "Compare fragment arguments regardless of..." · Reviewed by Greptile