Add GraphQL mutation to create a new release
What does this MR do?
Adds a GraphQL mutation to create a new release.
This is the GraphQL equivalent of the POST api/v4/projects/:id/releases
API endpoint. It follows the same permission model (only Developers or higher are allowed to create releases.)
Example query/response
Query:
mutation ($input: ReleaseCreateInput!) {
releaseCreate(input: $input) {
release {
tagName
name
description
createdAt
releasedAt
milestones {
nodes {
title
}
}
assets {
links {
nodes {
name
url
linkType
external
directAssetUrl
}
}
}
}
errors
}
}
Variables:
{
"input": {
"projectPath": "root/release-test",
"tagName": "v6.0.68",
"ref": "master",
"name": "GraphQL Release",
"description": "A release created through our GraphQL endpoint :rocket:",
"milestones": ["12.3", "12.4"],
"releasedAt": "2018-12-10",
"assets": {
"links": [{
"name": "A link with a permanent path",
"url": "https://example.com/link",
"filepath": "/my/link",
"linkType": "OTHER"
}]
}
}
}
When the user has at least Developer permissions
Response:
{
"data": {
"releaseCreate": {
"release": {
"tagName": "v6.0.68",
"name": "GraphQL Release",
"description": "A release created through our GraphQL endpoint :rocket:",
"createdAt": "2020-10-30T17:47:49Z",
"releasedAt": "2018-12-10T05:00:00Z",
"milestones": {
"nodes": [
{
"title": "12.4"
},
{
"title": "12.3"
}
]
},
"assets": {
"links": {
"nodes": [
{
"name": "A link with a permanent path",
"url": "https://example.com/link",
"linkType": "OTHER",
"external": true,
"directAssetUrl": "http://0.0.0.0:3000/root/release-test/-/releases/v6.0.68/my/link"
}
]
}
}
},
"errors": []
}
}
}
When a validation error occurs
Response:
{
"data": {
"releaseCreate": {
"release": null,
"errors": [
"Release already exists"
]
}
}
}
When the user has at most Reporter permissions
Response:
{
"data": {
"releaseCreate": 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": 2,
"column": 3
}
],
"path": [
"releaseCreate"
]
}
]
}
Related to #243727 (closed)
Edited by Nathan Friend