Add GraphQL mutation to create release asset link
What does this MR do?
Adds a GraphQL mutation - releaseAssetLinkCreate
- to create a new release asset link.
This new mutation is equivalent to the existing REST API creation endpoint:
POST /projects/:id/releases/:tag_name/assets/links
Example query/response
When a link is successfully created
Query:
mutation {
releaseAssetLinkCreate(input: {
projectPath: "root/release-test",
tagName: "v4.5",
name: "a new asset link",
url: "https://example.com/a-new-asset-link"
}) {
link {
id
}
errors
}
}
Response:
{
"data": {
"releaseAssetLinkCreate": {
"link": {
"id": "gid://gitlab/Releases::Link/184"
},
"errors": []
}
}
}
When the project doesn't exist
Query:
mutation {
releaseAssetLinkCreate(input: {
projectPath: "root/fake-project",
tagName: "fake-tag",
name: "my new link",
url: "https://example.com/new-link"
}) {
link {
id
}
errors
}
}
Response:
{
"data": {
"releaseAssetLinkCreate": 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": [
"releaseAssetLinkCreate"
]
}
]
}
When the release doesn't exist
Query:
mutation {
releaseAssetLinkCreate(input: {
projectPath: "root/release-test",
tagName: "fake-tag",
name: "my new link",
url: "https://example.com/new-link"
}) {
link {
id
}
errors
}
}
Response:
{
"data": {
"releaseAssetLinkCreate": {
"link": null,
"errors": [
"Release with tag \"fake-tag\" was not found"
]
}
}
}
When a validation error occurs
Query:
mutation {
releaseAssetLinkCreate(input: {
projectPath: "root/release-test",
tagName: "v4.5",
name: "my new link",
url: "https://example.com/new-link"
}) {
link {
id
}
errors
}
}
Response:
{
"data": {
"releaseAssetLinkCreate": {
"link": null,
"errors": [
"Url has already been taken",
"Name has already been taken"
]
}
}
}
Permissions
Permissions for this endpoint mirror the existing REST API endpoint.
Edited by Nathan Friend