# bex-api's services surface (backend/internal/api/graphql.go), Render-shaped:
# `services` lists every App; `suspendService`/`resumeService`/`restartServer`
# are Render's dashboard mutation names, each returning the updated Service.
# `suspended` is Render's string enum ("suspended"/"not_suspended"), NOT a bool;
# `phase`/`replicas`/`revision`/`plan` are bex-native extras (a superset Render
# ignores). `plan` (w1/m8) is null for an untiered (bare-CR) App. GraphQL
# exposes the live URL as a flat `url` field (REST nests it under
# serviceDetails.url — the two surfaces differ here by design).

# ownerId scopes the list to one workspace (w6/m2/t004's REST/GraphQL filter) —
# the dashboard's workspace switcher (w6/m3) passes the selected workspace's id;
# omitted, bex-api falls back to the caller's default workspace.
query Services($ownerId: String) {
  services(ownerId: $ownerId) {
    id
    name
    type
    suspended
    dashboardUrl
    url
    createdAt
    phase
    replicas
    revision
    plan
    idleTTLSeconds
  }
}

mutation SuspendService($id: String!) {
  suspendService(id: $id) {
    id
    suspended
    phase
  }
}

mutation ResumeService($id: String!) {
  resumeService(id: $id) {
    id
    suspended
    phase
  }
}

mutation RestartServer($id: String!) {
  restartServer(id: $id) {
    id
    suspended
    phase
  }
}

# deleteService returns a success boolean — there's no service left to select
# (backend/internal/apps/graphql.go, following the deleteDatabase shape). The
# dashboard danger zone (w5/m14) gates it behind a typed-name confirm.
mutation DeleteService($id: String!) {
  deleteService(id: $id)
}

# The create wizard's submit (w5/m15): exactly one of repo (build-from-git) or
# image must be set; branch/rootDir/autoDeploy apply to git sources only.
mutation CreateService(
  $name: String!
  $repo: String
  $image: String
  $branch: String
  $rootDir: String
  $plan: String
  $autoDeploy: Boolean
) {
  createService(
    name: $name
    repo: $repo
    image: $image
    branch: $branch
    rootDir: $rootDir
    plan: $plan
    autoDeploy: $autoDeploy
  ) {
    id
    name
    type
    phase
  }
}
