capability_id: pr.reviews.submit
version: "1.0.0"
description: Submit a pull request review (approve, request changes, or comment). GitHub requires a non-empty body for COMMENT and REQUEST_CHANGES events.
input_schema:
  type: object
  required: [owner, name, prNumber, event]
  properties:
    owner: { type: string, minLength: 1 }
    name: { type: string, minLength: 1 }
    prNumber: { type: integer, minimum: 1 }
    event:
      type: string
      # Uppercase values are canonical (GitHub's GraphQL enum); lowercase aliases
      # are accepted for consistency with pr.merge. Normalization happens in the
      # GraphQL handler.
      enum: [APPROVE, COMMENT, REQUEST_CHANGES, approve, comment, request_changes]
    body:
      type: string
      minLength: 1
      description: "Required when event is COMMENT or REQUEST_CHANGES. Optional for APPROVE."
    comments:
      type: array
      items:
        type: object
        required: [path, body, line]
        properties:
          path: { type: string, minLength: 1 }
          body: { type: string, minLength: 1 }
          line: { type: integer, minimum: 1 }
          side:
            type: string
            # Uppercase values are canonical (GitHub's GraphQL enum); lowercase aliases accepted.
            enum: [LEFT, RIGHT, left, right]
            description: "Diff side of the comment line (LEFT=base, RIGHT=head). Returned as diffSide in pr.threads.list output."
          startLine:
            type: integer
            minimum: 1
            description: "First line of a multi-line comment range. Omit for single-line comments."
          startSide:
            type: string
            # Uppercase values are canonical (GitHub's GraphQL enum); lowercase aliases accepted.
            enum: [LEFT, RIGHT, left, right]
            description: "Diff side of startLine (LEFT=base, RIGHT=head). Required if startLine is set."
        additionalProperties: false
  additionalProperties: false
output_schema:
  type: object
  required: [id, state, url, body]
  properties:
    id: { type: [string, "null"] }
    state: { type: [string, "null"] }
    url: { type: [string, "null"] }
    body: { type: [string, "null"] }
  additionalProperties: false
routing:
  preferred: graphql
  fallbacks: []
graphql:
  operationName: PrReviewSubmit
  operationType: mutation
  documentPath: src/gql/operations/pr-review-submit.graphql
  resolution:
    lookup:
      operationName: PrNodeId
      documentPath: src/gql/operations/pr-node-id.graphql
      vars:
        owner: owner
        name: name
        prNumber: prNumber
    inject:
      - target: pullRequestId
        source: scalar
        path: repository.pullRequest.id
      - target: event
        source: input_upper
        from_input: event
      - target: threads
        source: draft_review_threads
        from_input: comments
