Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

589 lines · 18.7 KBRaw History
1/**
2 * The part of GitHub's GraphQL schema (https://docs.github.com/graphql) that Diffinery answers at
3 * /api/graphql. Names, types and enum values are GitHub's, so the GitHub CLI and tools built on it
4 * (Claude Code's pull request badge, `gh pr view`, `gh pr checks`, `gh pr list`, `gh pr status`,
5 * `gh pr create`, `gh pr merge`, `gh pr ready`, `gh pr comment`) read and change Diffinery as a
6 * GitHub Enterprise Server host. The mutations are the pull request ones gh uses; everything else
7 * changes through the REST API.
8 */
9export const SCHEMA_SDL = /* GraphQL */ `
10"""Ids from the REST API, which can be wider than GraphQL's 32-bit Int (GitHub types these as Int)."""
11scalar BigInt
12scalar DateTime
13scalar URI
14scalar GitObjectID
15scalar HTML
16scalar GitTimestamp
17
18schema { query: Query, mutation: Mutation }
19
20type Mutation {
21 addAssigneesToAssignable(input: AddAssigneesToAssignableInput!): AddAssigneesToAssignablePayload
22 addComment(input: AddCommentInput!): AddCommentPayload
23 addLabelsToLabelable(input: AddLabelsToLabelableInput!): AddLabelsToLabelablePayload
24 closePullRequest(input: ClosePullRequestInput!): ClosePullRequestPayload
25 convertPullRequestToDraft(input: ConvertPullRequestToDraftInput!): ConvertPullRequestToDraftPayload
26 createPullRequest(input: CreatePullRequestInput!): CreatePullRequestPayload
27 disablePullRequestAutoMerge(input: DisablePullRequestAutoMergeInput!): DisablePullRequestAutoMergePayload
28 enablePullRequestAutoMerge(input: EnablePullRequestAutoMergeInput!): EnablePullRequestAutoMergePayload
29 markPullRequestReadyForReview(input: MarkPullRequestReadyForReviewInput!): MarkPullRequestReadyForReviewPayload
30 mergePullRequest(input: MergePullRequestInput!): MergePullRequestPayload
31 removeAssigneesFromAssignable(input: RemoveAssigneesFromAssignableInput!): RemoveAssigneesFromAssignablePayload
32 removeLabelsFromLabelable(input: RemoveLabelsFromLabelableInput!): RemoveLabelsFromLabelablePayload
33 reopenPullRequest(input: ReopenPullRequestInput!): ReopenPullRequestPayload
34 requestReviews(input: RequestReviewsInput!): RequestReviewsPayload
35 updatePullRequest(input: UpdatePullRequestInput!): UpdatePullRequestPayload
36}
37
38input CreatePullRequestInput {
39 baseRefName: String!
40 body: String
41 clientMutationId: String
42 draft: Boolean = false
43 headRefName: String!
44 headRepositoryId: ID
45 maintainerCanModify: Boolean = true
46 repositoryId: ID!
47 title: String!
48}
49type CreatePullRequestPayload { clientMutationId: String, pullRequest: PullRequest }
50
51input UpdatePullRequestInput {
52 assigneeIds: [ID!]
53 baseRefName: String
54 body: String
55 clientMutationId: String
56 labelIds: [ID!]
57 maintainerCanModify: Boolean
58 milestoneId: ID
59 projectIds: [ID!]
60 pullRequestId: ID!
61 state: PullRequestUpdateState
62 title: String
63}
64enum PullRequestUpdateState { OPEN CLOSED }
65type UpdatePullRequestPayload { actor: Actor, clientMutationId: String, pullRequest: PullRequest }
66
67input ClosePullRequestInput { clientMutationId: String, pullRequestId: ID! }
68type ClosePullRequestPayload { clientMutationId: String, pullRequest: PullRequest }
69input ReopenPullRequestInput { clientMutationId: String, pullRequestId: ID! }
70type ReopenPullRequestPayload { clientMutationId: String, pullRequest: PullRequest }
71input MarkPullRequestReadyForReviewInput { clientMutationId: String, pullRequestId: ID! }
72type MarkPullRequestReadyForReviewPayload { clientMutationId: String, pullRequest: PullRequest }
73input ConvertPullRequestToDraftInput { clientMutationId: String, pullRequestId: ID! }
74type ConvertPullRequestToDraftPayload { clientMutationId: String, pullRequest: PullRequest }
75
76input EnablePullRequestAutoMergeInput {
77 authorEmail: String
78 clientMutationId: String
79 commitBody: String
80 commitHeadline: String
81 expectedHeadOid: GitObjectID
82 mergeMethod: PullRequestMergeMethod = MERGE
83 pullRequestId: ID!
84}
85type EnablePullRequestAutoMergePayload { actor: Actor, clientMutationId: String, pullRequest: PullRequest }
86input DisablePullRequestAutoMergeInput { clientMutationId: String, pullRequestId: ID! }
87type DisablePullRequestAutoMergePayload { actor: Actor, clientMutationId: String, pullRequest: PullRequest }
88
89input MergePullRequestInput {
90 authorEmail: String
91 clientMutationId: String
92 commitBody: String
93 commitHeadline: String
94 expectedHeadOid: GitObjectID
95 mergeMethod: PullRequestMergeMethod = MERGE
96 pullRequestId: ID!
97}
98type MergePullRequestPayload { actor: Actor, clientMutationId: String, pullRequest: PullRequest }
99
100input AddCommentInput { body: String!, clientMutationId: String, subjectId: ID! }
101type IssueCommentEdge { cursor: String!, node: IssueComment }
102type AddCommentPayload { clientMutationId: String, commentEdge: IssueCommentEdge, subject: Node }
103
104input AddLabelsToLabelableInput { clientMutationId: String, labelableId: ID!, labelIds: [ID!]! }
105type AddLabelsToLabelablePayload { clientMutationId: String, labelable: PullRequest }
106input RemoveLabelsFromLabelableInput { clientMutationId: String, labelableId: ID!, labelIds: [ID!]! }
107type RemoveLabelsFromLabelablePayload { clientMutationId: String, labelable: PullRequest }
108input AddAssigneesToAssignableInput { clientMutationId: String, assignableId: ID!, assigneeIds: [ID!]! }
109type AddAssigneesToAssignablePayload { clientMutationId: String, assignable: PullRequest }
110input RemoveAssigneesFromAssignableInput { clientMutationId: String, assignableId: ID!, assigneeIds: [ID!]! }
111type RemoveAssigneesFromAssignablePayload { clientMutationId: String, assignable: PullRequest }
112
113input RequestReviewsInput {
114 clientMutationId: String
115 pullRequestId: ID!
116 teamIds: [ID!]
117 union: Boolean = false
118 userIds: [ID!]
119}
120type RequestReviewsPayload { actor: Actor, clientMutationId: String, pullRequest: PullRequest }
121
122type Query {
123 "The signed-in account."
124 viewer: User!
125 "A repository by owner and name."
126 repository(owner: String!, name: String!, followRenames: Boolean = true): Repository
127 "An account by login."
128 user(login: String!): User
129 "Request budget, reported as GitHub does. Diffinery limits requests per account rather than by query cost."
130 rateLimit(dryRun: Boolean = false): RateLimit
131 "A repository or pull request by its global id."
132 node(id: ID!): Node
133 nodes(ids: [ID!]!): [Node]!
134 "Pull requests in one repository (the query needs a repo: qualifier), as \`gh pr status\` asks for them."
135 search(query: String!, type: SearchType!, first: Int, last: Int, after: String, before: String): SearchResultItemConnection!
136}
137
138enum SearchType { ISSUE ISSUE_ADVANCED REPOSITORY USER DISCUSSION }
139union SearchResultItem = PullRequest
140type SearchResultItemEdge { cursor: String!, node: SearchResultItem }
141type SearchResultItemConnection {
142 edges: [SearchResultItemEdge]
143 issueCount: Int!
144 nodes: [SearchResultItem]
145 pageInfo: PageInfo!
146 repositoryCount: Int!
147 userCount: Int!
148}
149
150enum ReactionContent { THUMBS_UP THUMBS_DOWN LAUGH HOORAY CONFUSED HEART ROCKET EYES }
151type ReactingUserConnection { totalCount: Int! }
152type ReactionGroup {
153 content: ReactionContent!
154 users(first: Int, last: Int, after: String, before: String): ReactingUserConnection!
155 viewerHasReacted: Boolean!
156}
157
158type RateLimit {
159 cost: Int!
160 limit: Int!
161 nodeCount: Int!
162 remaining: Int!
163 resetAt: DateTime!
164 used: Int!
165}
166
167type PageInfo {
168 endCursor: String
169 hasNextPage: Boolean!
170 hasPreviousPage: Boolean!
171 startCursor: String
172}
173
174interface Node { id: ID! }
175
176interface Actor {
177 avatarUrl(size: Int): URI!
178 login: String!
179 resourcePath: URI!
180 url: URI!
181}
182
183interface RepositoryOwner {
184 avatarUrl(size: Int): URI!
185 id: ID!
186 login: String!
187 resourcePath: URI!
188 url: URI!
189}
190
191type User implements Node & Actor & RepositoryOwner {
192 avatarUrl(size: Int): URI!
193 databaseId: BigInt
194 email: String!
195 id: ID!
196 isBot: Boolean!
197 login: String!
198 name: String
199 resourcePath: URI!
200 url: URI!
201}
202
203type Organization implements Node & Actor & RepositoryOwner {
204 avatarUrl(size: Int): URI!
205 databaseId: BigInt
206 id: ID!
207 login: String!
208 name: String
209 resourcePath: URI!
210 url: URI!
211}
212
213type Bot implements Node & Actor {
214 avatarUrl(size: Int): URI!
215 databaseId: BigInt
216 id: ID!
217 login: String!
218 resourcePath: URI!
219 url: URI!
220}
221
222"Someone brought over by a GitHub import who has no Diffinery account."
223type Mannequin implements Node & Actor {
224 avatarUrl(size: Int): URI!
225 id: ID!
226 login: String!
227 resourcePath: URI!
228 url: URI!
229}
230
231enum RepositoryPermission { ADMIN MAINTAIN WRITE TRIAGE READ }
232enum RepositoryVisibility { PRIVATE PUBLIC INTERNAL }
233enum PullRequestState { OPEN CLOSED MERGED }
234enum IssueState { OPEN CLOSED }
235enum OrderDirection { ASC DESC }
236enum IssueOrderField { CREATED_AT UPDATED_AT COMMENTS }
237input IssueOrder { field: IssueOrderField!, direction: OrderDirection! }
238enum LabelOrderField { NAME CREATED_AT }
239input LabelOrder { field: LabelOrderField!, direction: OrderDirection! }
240enum MilestoneState { OPEN CLOSED }
241enum MilestoneOrderField { DUE_DATE CREATED_AT UPDATED_AT NUMBER }
242input MilestoneOrder { field: MilestoneOrderField!, direction: OrderDirection! }
243enum PullRequestReviewDecision { CHANGES_REQUESTED APPROVED REVIEW_REQUIRED }
244enum PullRequestReviewState { PENDING COMMENTED APPROVED CHANGES_REQUESTED DISMISSED }
245enum MergeableState { MERGEABLE CONFLICTING UNKNOWN }
246enum MergeStateStatus { DIRTY UNKNOWN BLOCKED BEHIND DRAFT UNSTABLE HAS_HOOKS CLEAN }
247enum PullRequestMergeMethod { MERGE SQUASH REBASE }
248enum StatusState { EXPECTED ERROR FAILURE PENDING SUCCESS }
249enum CheckStatusState { REQUESTED QUEUED IN_PROGRESS COMPLETED WAITING PENDING }
250enum CheckConclusionState { ACTION_REQUIRED TIMED_OUT CANCELLED FAILURE SUCCESS NEUTRAL SKIPPED STARTUP_FAILURE STALE }
251enum CheckRunState { REQUESTED QUEUED IN_PROGRESS COMPLETED WAITING PENDING ACTION_REQUIRED TIMED_OUT CANCELLED FAILURE SUCCESS NEUTRAL SKIPPED STARTUP_FAILURE STALE }
252enum PatchStatus { ADDED DELETED RENAMED COPIED MODIFIED CHANGED }
253
254type Repository implements Node {
255 assignableUsers(first: Int, last: Int, after: String, before: String, query: String): UserConnection!
256 createdAt: DateTime!
257 databaseId: BigInt
258 defaultBranchRef: Ref
259 deleteBranchOnMerge: Boolean!
260 description: String
261 hasDiscussionsEnabled: Boolean!
262 hasIssuesEnabled: Boolean!
263 hasProjectsEnabled: Boolean!
264 hasWikiEnabled: Boolean!
265 homepageUrl: URI
266 id: ID!
267 isArchived: Boolean!
268 isEmpty: Boolean!
269 isFork: Boolean!
270 isInOrganization: Boolean!
271 isLocked: Boolean!
272 isMirror: Boolean!
273 isPrivate: Boolean!
274 isTemplate: Boolean!
275 label(name: String!): Label
276 labels(first: Int, last: Int, after: String, before: String, query: String, orderBy: LabelOrder): LabelConnection
277 mentionableUsers(first: Int, last: Int, after: String, before: String, query: String): UserConnection!
278 mergeCommitAllowed: Boolean!
279 milestones(first: Int, last: Int, after: String, before: String, states: [MilestoneState!], orderBy: MilestoneOrder, query: String): MilestoneConnection
280 name: String!
281 nameWithOwner: String!
282 owner: RepositoryOwner!
283 parent: Repository
284 pullRequest(number: Int!): PullRequest
285 pullRequests(first: Int, last: Int, after: String, before: String, states: [PullRequestState!], headRefName: String, baseRefName: String, labels: [String!], orderBy: IssueOrder): PullRequestConnection!
286 pushedAt: DateTime
287 rebaseMergeAllowed: Boolean!
288 resourcePath: URI!
289 squashMergeAllowed: Boolean!
290 sshUrl: String!
291 updatedAt: DateTime!
292 url: URI!
293 viewerCanAdminister: Boolean!
294 viewerPermission: RepositoryPermission
295 visibility: RepositoryVisibility!
296}
297
298type Ref implements Node {
299 branchProtectionRule: BranchProtectionRule
300 id: ID!
301 name: String!
302 prefix: String!
303 target: Commit
304}
305
306type BranchProtectionRule implements Node {
307 id: ID!
308 pattern: String!
309 requiredApprovingReviewCount: Int
310 requiredStatusCheckContexts: [String]
311 requiresApprovingReviews: Boolean!
312 requiresLinearHistory: Boolean!
313 requiresStatusChecks: Boolean!
314 requiresStrictStatusChecks: Boolean!
315}
316
317type PullRequestConnection {
318 edges: [PullRequestEdge]
319 nodes: [PullRequest]
320 pageInfo: PageInfo!
321 totalCount: Int!
322}
323type PullRequestEdge { cursor: String!, node: PullRequest }
324
325type PullRequest implements Node {
326 additions: Int!
327 assignees(first: Int, last: Int, after: String, before: String): UserConnection!
328 author: Actor
329 authorAssociation: String!
330 autoMergeRequest: AutoMergeRequest
331 baseRef: Ref
332 baseRefName: String!
333 baseRefOid: GitObjectID!
334 baseRepository: Repository
335 body: String!
336 changedFiles: Int!
337 closed: Boolean!
338 closedAt: DateTime
339 comments(first: Int, last: Int, after: String, before: String): IssueCommentConnection!
340 commits(first: Int, last: Int, after: String, before: String): PullRequestCommitConnection!
341 createdAt: DateTime!
342 databaseId: BigInt
343 deletions: Int!
344 files(first: Int, last: Int, after: String, before: String): PullRequestChangedFileConnection
345 headRef: Ref
346 headRefName: String!
347 headRefOid: GitObjectID!
348 headRepository: Repository
349 headRepositoryOwner: RepositoryOwner
350 id: ID!
351 isCrossRepository: Boolean!
352 isDraft: Boolean!
353 labels(first: Int, last: Int, after: String, before: String): LabelConnection
354 latestReviews(first: Int, last: Int, after: String, before: String): PullRequestReviewConnection
355 locked: Boolean!
356 maintainerCanModify: Boolean!
357 mergeCommit: Commit
358 mergeStateStatus: MergeStateStatus!
359 mergeable: MergeableState!
360 merged: Boolean!
361 mergedAt: DateTime
362 mergedBy: Actor
363 milestone: Milestone
364 number: Int!
365 permalink: URI!
366 projectItems(first: Int, last: Int, after: String, before: String): ProjectV2ItemConnection!
367 reactionGroups: [ReactionGroup!]
368 repository: Repository!
369 resourcePath: URI!
370 reviewDecision: PullRequestReviewDecision
371 reviewRequests(first: Int, last: Int, after: String, before: String): ReviewRequestConnection
372 reviews(first: Int, last: Int, after: String, before: String, states: [PullRequestReviewState!]): PullRequestReviewConnection
373 state: PullRequestState!
374 statusCheckRollup: StatusCheckRollup
375 title: String!
376 updatedAt: DateTime!
377 url: URI!
378}
379
380type AutoMergeRequest {
381 authorEmail: String
382 commitBody: String
383 commitHeadline: String
384 enabledAt: DateTime
385 enabledBy: Actor
386 mergeMethod: PullRequestMergeMethod!
387}
388
389type Milestone implements Node {
390 description: String
391 dueOn: DateTime
392 id: ID!
393 number: Int!
394 state: String!
395 title: String!
396}
397
398type MilestoneConnection { nodes: [Milestone], totalCount: Int!, pageInfo: PageInfo! }
399
400type UserConnection { nodes: [User], totalCount: Int!, pageInfo: PageInfo! }
401
402type Label implements Node {
403 color: String!
404 description: String
405 id: ID!
406 name: String!
407}
408type LabelConnection { nodes: [Label], totalCount: Int!, pageInfo: PageInfo! }
409
410type Team implements Node {
411 id: ID!
412 name: String!
413 organization: Organization!
414 slug: String!
415}
416union RequestedReviewer = User | Team | Bot | Mannequin
417type ReviewRequest { requestedReviewer: RequestedReviewer }
418type ReviewRequestConnection { nodes: [ReviewRequest], totalCount: Int!, pageInfo: PageInfo! }
419
420type PullRequestReview implements Node {
421 author: Actor
422 authorAssociation: String!
423 body: String!
424 commit: Commit
425 id: ID!
426 includesCreatedEdit: Boolean!
427 reactionGroups: [ReactionGroup!]
428 state: PullRequestReviewState!
429 submittedAt: DateTime
430}
431type PullRequestReviewConnection { nodes: [PullRequestReview], totalCount: Int!, pageInfo: PageInfo! }
432
433type IssueComment implements Node {
434 author: Actor
435 authorAssociation: String!
436 body: String!
437 createdAt: DateTime!
438 id: ID!
439 includesCreatedEdit: Boolean!
440 isMinimized: Boolean!
441 minimizedReason: String
442 reactionGroups: [ReactionGroup!]
443 url: URI!
444 viewerDidAuthor: Boolean!
445}
446type IssueCommentConnection { nodes: [IssueComment], totalCount: Int!, pageInfo: PageInfo! }
447
448type PullRequestChangedFile {
449 additions: Int!
450 changeType: PatchStatus!
451 deletions: Int!
452 path: String!
453}
454type PullRequestChangedFileConnection { nodes: [PullRequestChangedFile], totalCount: Int!, pageInfo: PageInfo! }
455
456type PullRequestCommit implements Node {
457 commit: Commit!
458 id: ID!
459 url: URI!
460}
461type PullRequestCommitEdge { cursor: String!, node: PullRequestCommit }
462type PullRequestCommitConnection {
463 edges: [PullRequestCommitEdge]
464 nodes: [PullRequestCommit]
465 pageInfo: PageInfo!
466 totalCount: Int!
467}
468
469type GitActor {
470 date: GitTimestamp
471 email: String
472 name: String
473 user: User
474}
475
476type GitActorConnection { nodes: [GitActor], totalCount: Int!, pageInfo: PageInfo! }
477
478"Projects aren't part of Diffinery: always empty."
479type ProjectV2Item implements Node { id: ID! }
480type ProjectV2ItemConnection { nodes: [ProjectV2Item], totalCount: Int!, pageInfo: PageInfo! }
481
482type Commit implements Node {
483 abbreviatedOid: String!
484 author: GitActor
485 authoredDate: DateTime!
486 authors(first: Int, last: Int, after: String, before: String): GitActorConnection!
487 commitUrl: URI!
488 committedDate: DateTime!
489 committer: GitActor
490 id: ID!
491 message: String!
492 messageBody: String!
493 messageHeadline: String!
494 oid: GitObjectID!
495 status: Status
496 statusCheckRollup: StatusCheckRollup
497 url: URI!
498}
499
500"The legacy combined commit status (commit statuses only, no check runs)."
501type Status implements Node {
502 contexts: [StatusContext!]!
503 id: ID!
504 state: StatusState!
505}
506
507type StatusCheckRollup implements Node {
508 commit: Commit
509 contexts(first: Int, last: Int, after: String, before: String): StatusCheckRollupContextConnection!
510 id: ID!
511 state: StatusState!
512}
513
514union StatusCheckRollupContext = CheckRun | StatusContext
515
516type CheckRunStateCount { count: Int!, state: CheckRunState! }
517type StatusContextStateCount { count: Int!, state: StatusState! }
518type StatusCheckRollupContextEdge { cursor: String!, node: StatusCheckRollupContext }
519
520type StatusCheckRollupContextConnection {
521 checkRunCount: Int!
522 checkRunCountsByState: [CheckRunStateCount!]
523 edges: [StatusCheckRollupContextEdge]
524 nodes: [StatusCheckRollupContext]
525 pageInfo: PageInfo!
526 statusContextCount: Int!
527 statusContextCountsByState: [StatusContextStateCount!]
528 totalCount: Int!
529}
530
531type App implements Node {
532 id: ID!
533 logoUrl(size: Int): URI!
534 name: String!
535 slug: String!
536}
537
538type Workflow implements Node {
539 id: ID!
540 name: String!
541}
542
543type WorkflowRun implements Node {
544 databaseId: BigInt
545 event: String!
546 id: ID!
547 runNumber: Int!
548 url: URI!
549 workflow: Workflow!
550}
551
552type CheckSuite implements Node {
553 app: App
554 conclusion: CheckConclusionState
555 id: ID!
556 status: CheckStatusState!
557 workflowRun: WorkflowRun
558}
559
560type CheckRun implements Node {
561 checkSuite: CheckSuite!
562 completedAt: DateTime
563 conclusion: CheckConclusionState
564 databaseId: BigInt
565 detailsUrl: URI
566 id: ID!
567 isRequired(pullRequestId: ID, pullRequestNumber: Int): Boolean!
568 name: String!
569 permalink: URI!
570 startedAt: DateTime
571 status: CheckStatusState!
572 summary: String
573 text: String
574 title: String
575 url: URI!
576}
577
578type StatusContext implements Node {
579 avatarUrl(size: Int): URI
580 context: String!
581 createdAt: DateTime!
582 creator: Actor
583 description: String
584 id: ID!
585 isRequired(pullRequestId: ID, pullRequestNumber: Int): Boolean!
586 state: StatusState!
587 targetUrl: URI
588}
589`;