Swadhin Biswas Feature/ai code reviewer (#79) · 8/16/2026
cfd400d
552 lines · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
/**
 * GraphQL Schema Definitions
 * Type definitions for OpenCodeHub GraphQL API
 */

export const typeDefs = /* GraphQL */ `
  scalar DateTime

  type Query {
    # User queries
    viewer: User
    user(username: String!): User
    
    # Repository queries  
    repository(owner: String!, name: String!): Repository

    # Issue queries (WS5-02)
    issue(owner: String!, repo: String!, number: Int!): Issue

    # Organization queries (WS5-02)
    organization(login: String!): Organization
    
    # Search
    search(query: String!, type: SearchType!, first: Int = 10, after: String): SearchConnection!
  }

  type Mutation {
    # Repository mutations
    createRepository(input: CreateRepositoryInput!): CreateRepositoryPayload!
    
    # Pull request mutations
    createPullRequest(input: CreatePullRequestInput!): CreatePullRequestPayload!
    mergePullRequest(input: MergePullRequestInput!): MergePullRequestPayload!
    updatePullRequest(input: UpdatePullRequestInput!): UpdatePullRequestPayload!
    
    # Review mutations
    addPullRequestReview(input: AddPullRequestReviewInput!): AddPullRequestReviewPayload!
    
    # Comment mutations
    addComment(input: AddCommentInput!): AddCommentPayload!

    # Issue mutations (WS5-02)
    createIssue(input: CreateIssueInput!): CreateIssuePayload!
    updateIssue(input: UpdateIssueInput!): UpdateIssuePayload!

    # Labels (WS5-02)
    addLabels(input: AddLabelsInput!): AddLabelsPayload!
  }

  enum SearchType {
    REPOSITORY
    USER
    ISSUE
    PULL_REQUEST
  }

  # ============ User Types ============
  type User {
    id: ID!
    username: String!
    displayName: String
    email: String
    avatarUrl: String
    bio: String
    location: String
    website: String
    createdAt: DateTime!
    
    repositories(first: Int = 10, after: String): RepositoryConnection!
    pullRequests(first: Int = 10, states: [PullRequestState!]): PullRequestConnection!
    organizations: [Organization!]!
  }

  type Organization {
    id: ID!
    name: String!
    displayName: String
    avatarUrl: String
    description: String
    members(first: Int = 10): UserConnection!
    repositories(first: Int = 10): RepositoryConnection!
  }

  # ============ Repository Types ============
  type Repository {
    id: ID!
    name: String!
    fullName: String!
    description: String
    isPrivate: Boolean!
    isFork: Boolean!
    isArchived: Boolean!
    
    owner: User!
    defaultBranch: String!
    
    # Stats
    stargazerCount: Int!
    forkCount: Int!
    watcherCount: Int!
    
    # Content
    ref(qualifiedName: String!): Ref
    refs(first: Int = 10, refPrefix: String = "refs/heads/"): RefConnection!
    
    # Issues and PRs
    issues(first: Int = 10, states: [IssueState!]): IssueConnection!
    pullRequests(first: Int = 10, states: [PullRequestState!]): PullRequestConnection!
    
    # Metadata
    languages: [LanguageEdge!]!
    topics: [String!]!
    licenseInfo: License
    
    createdAt: DateTime!
    updatedAt: DateTime!
    pushedAt: DateTime
  }

  type Ref {
    name: String!
    prefix: String!
    target: GitObject!
  }

  interface GitObject {
    oid: String!
    abbreviatedOid: String!
  }

  type Commit implements GitObject {
    oid: String!
    abbreviatedOid: String!
    message: String!
    messageHeadline: String!
    messageBody: String
    author: GitActor!
    committer: GitActor!
    authoredDate: DateTime!
    committedDate: DateTime!
    parents(first: Int = 10): CommitConnection!
    tree: Tree!
  }

  type Tree implements GitObject {
    oid: String!
    abbreviatedOid: String!
    entries: [TreeEntry!]!
  }

  type TreeEntry {
    name: String!
    path: String!
    type: String!
    mode: Int!
    object: GitObject
  }

  type GitActor {
    name: String
    email: String
    date: DateTime
    user: User
  }

  type License {
    key: String!
    name: String!
    spdxId: String
    url: String
  }

  type LanguageEdge {
    node: Language!
    size: Int!
  }

  type Language {
    name: String!
    color: String
  }

  # ============ Issue Types ============
  type Issue {
    id: ID!
    number: Int!
    title: String!
    body: String
    state: IssueState!
    author: User!
    assignees(first: Int = 5): UserConnection!
    labels(first: Int = 10): LabelConnection!
    comments(first: Int = 10): CommentConnection!
    milestone: Milestone
    createdAt: DateTime!
    updatedAt: DateTime!
    closedAt: DateTime
  }

  enum IssueState {
    OPEN
    CLOSED
  }

  type Label {
    id: ID!
    name: String!
    color: String!
    description: String
  }

  type Milestone {
    id: ID!
    title: String!
    description: String
    dueOn: DateTime
    state: MilestoneState!
    progressPercentage: Float!
  }

  enum MilestoneState {
    OPEN
    CLOSED
  }

  # ============ Pull Request Types ============
  type PullRequest {
    id: ID!
    number: Int!
    title: String!
    body: String
    state: PullRequestState!
    isDraft: Boolean!
    
    author: User!
    headRefName: String!
    headRefOid: String!
    baseRefName: String!
    baseRefOid: String!
    
    mergeable: MergeableState!
    merged: Boolean!
    mergedAt: DateTime
    mergedBy: User
    
    additions: Int!
    deletions: Int!
    changedFiles: Int!
    
    commits(first: Int = 10): CommitConnection!
    files(first: Int = 100): PullRequestChangedFileConnection!
    reviews(first: Int = 10): PullRequestReviewConnection!
    comments(first: Int = 10): CommentConnection!
    reviewRequests(first: Int = 10): ReviewRequestConnection!
    
    assignees(first: Int = 5): UserConnection!
    labels(first: Int = 10): LabelConnection!
    
    createdAt: DateTime!
    updatedAt: DateTime!
    closedAt: DateTime
  }

  enum PullRequestState {
    OPEN
    CLOSED
    MERGED
  }

  enum MergeableState {
    MERGEABLE
    CONFLICTING
    UNKNOWN
  }

  type PullRequestChangedFile {
    path: String!
    additions: Int!
    deletions: Int!
    changeType: PatchStatus!
  }

  enum PatchStatus {
    ADDED
    DELETED
    MODIFIED
    RENAMED
    COPIED
    CHANGED
  }

  type PullRequestReview {
    id: ID!
    author: User!
    body: String
    state: PullRequestReviewState!
    submittedAt: DateTime
    comments(first: Int = 10): CommentConnection!
  }

  enum PullRequestReviewState {
    PENDING
    COMMENTED
    APPROVED
    CHANGES_REQUESTED
    DISMISSED
  }

  type ReviewRequest {
    id: ID!
    requestedReviewer: User!
    requestedAt: DateTime!
  }

  type Comment {
    id: ID!
    body: String!
    author: User!
    createdAt: DateTime!
    updatedAt: DateTime!
    
    # For inline comments
    path: String
    line: Int
    
    # Suggestion support
    suggestion: String
    suggestionApplied: Boolean
  }

  # ============ Connection Types ============
  type PageInfo {
    hasNextPage: Boolean!
    hasPreviousPage: Boolean!
    startCursor: String
    endCursor: String
  }

  type UserConnection {
    nodes: [User!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type RepositoryConnection {
    nodes: [Repository!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type IssueConnection {
    nodes: [Issue!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type PullRequestConnection {
    nodes: [PullRequest!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type CommitConnection {
    nodes: [Commit!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type RefConnection {
    nodes: [Ref!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type CommentConnection {
    nodes: [Comment!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type LabelConnection {
    nodes: [Label!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type PullRequestChangedFileConnection {
    nodes: [PullRequestChangedFile!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type PullRequestReviewConnection {
    nodes: [PullRequestReview!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type ReviewRequestConnection {
    nodes: [ReviewRequest!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  type SearchConnection {
    nodes: [SearchResultItem!]!
    pageInfo: PageInfo!
    totalCount: Int!
  }

  union SearchResultItem = Repository | User | Issue | PullRequest

  # ============ Input Types ============
  input CreateRepositoryInput {
    name: String!
    description: String
    visibility: RepositoryVisibility = PUBLIC
    hasIssues: Boolean = true
    hasWiki: Boolean = true
  }

  enum RepositoryVisibility {
    PUBLIC
    PRIVATE
  }

  input CreatePullRequestInput {
    repositoryId: ID!
    title: String!
    body: String
    headRefName: String!
    baseRefName: String!
    draft: Boolean = false
  }

  input MergePullRequestInput {
    pullRequestId: ID!
    mergeMethod: MergeMethod = MERGE
    commitTitle: String
    commitBody: String
  }

  enum MergeMethod {
    MERGE
    SQUASH
    REBASE
  }

  input AddPullRequestReviewInput {
    pullRequestId: ID!
    body: String
    event: PullRequestReviewEvent!
    comments: [DraftPullRequestReviewComment!]
  }

  enum PullRequestReviewEvent {
    COMMENT
    APPROVE
    REQUEST_CHANGES
  }

  input DraftPullRequestReviewComment {
    path: String!
    line: Int!
    body: String!
    suggestion: String
  }

  input AddCommentInput {
    subjectId: ID!
    body: String!
  }

  # ============ Issue Mutations (WS5-02) ============
  input CreateIssueInput {
    repositoryId: ID!
    title: String!
    body: String
    labelIds: [ID!]
    assigneeIds: [ID!]
    milestoneId: ID
  }

  input UpdateIssueInput {
    issueId: ID!
    title: String
    body: String
    state: IssueState
    milestoneId: ID
  }

  input UpdatePullRequestInput {
    pullRequestId: ID!
    title: String
    body: String
    draft: Boolean
  }

  input AddLabelsInput {
    subjectId: ID!
    labelIds: [ID!]!
  }

  # ============ Payload Types ============
  type CreateRepositoryPayload {
    repository: Repository
    clientMutationId: String
  }

  type CreatePullRequestPayload {
    pullRequest: PullRequest
    clientMutationId: String
  }

  type MergePullRequestPayload {
    pullRequest: PullRequest
    clientMutationId: String
  }

  type AddPullRequestReviewPayload {
    pullRequestReview: PullRequestReview
    clientMutationId: String
  }

  type AddCommentPayload {
    comment: Comment
    clientMutationId: String
  }

  type CreateIssuePayload {
    issue: Issue
    clientMutationId: String
  }

  type UpdateIssuePayload {
    issue: Issue
    clientMutationId: String
  }

  type UpdatePullRequestPayload {
    pullRequest: PullRequest
    clientMutationId: String
  }

  type AddLabelsPayload {
    subject: AddLabelsSubject
    clientMutationId: String
  }

  union AddLabelsSubject = Issue | PullRequest
`;