Skip to content

Add GraphQL mutation to delete release

Nathan Friend requested to merge nfriend-add-release-delete-mutation into master

What does this MR do?

Adds a GraphQL mutation to delete a release.

This is the GraphQL equivalent of the DELETE /projects/:id/releases/:tag_name API endpoint. It follows the same permission model (only Maintainers or higher are allowed to delete releases.)

Example query/response

Query:

mutation ReleaseDelete($deleteInput: ReleaseDeleteInput!) {
  releaseDelete(input: $deleteInput) {
    release {
      tagName
      name
    }
    errors
  }
}

Variables:

{
  "deleteInput": {
    "projectPath": "root/release-test",
    "tagName": "a-release-to-be-deleted"
  }
}

Response:

{
  "data": {
    "releaseDelete": {
      "release": {
        "tagName": "a-release-to-be-deleted",
        "name": "A release to be deleted"
      },
      "errors": []
    }
  }
}

When the user doesn't have permission to delete the release

{
  "data": {
    "releaseDelete": null
  },
  "errors": [
    {
      "message": "The resource that you are attempting to access does not exist or you don't have permission to perform this action",
      "locations": [
        {
          "line": 12,
          "column": 3
        }
      ],
      "path": [
        "releaseDelete"
      ]
    }
  ]
}

When the release doesn't exist

{
  "data": {
    "releaseDelete": {
      "release": null,
      "errors": [
        "Release does not exist"
      ]
    }
  }
}
Edited by Nathan Friend

Merge request reports

Loading