Skip to content

Add GraphQL mutation to update release asset link

What does this MR do?

Adds a GraphQL mutation - releaseAssetLinkUpdate - to update an existing release asset link.

This new mutation is equivalent to the existing REST API update endpoint:

PUT /projects/:id/releases/:tag_name/assets/links/:link_id

This MR is very similar to !54605 (merged), where a creation mutation was added.

Example query/response

When a link is successfully updated

Query:

mutation {
  releaseAssetLinkUpdate(input: {
    id: "gid://gitlab/Releases::Link/186",
    name: "Updated name",
    url: "https://example.com/updated/url",
    directAssetPath: "/updated/path",
    linkType: PACKAGE,
  }) {
    link {
      id
      name
      url
      directAssetUrl
      linkType
      external
    },
    errors
  }
}

Response:

{
  "data": {
    "releaseAssetLinkUpdate": {
      "link": {
        "id": "gid://gitlab/Releases::Link/186",
        "name": "Updated name",
        "url": "https://example.com/updated/url",
        "directAssetUrl": "http://0.0.0.0:3000/root/release-test/-/releases/v9.0.6/downloads/updated/path",
        "linkType": "PACKAGE",
        "external": true
      },
      "errors": []
    }
  }
}
When the provided link doesn't exist

In this example, there's no link with an ID of 999999.

Query:

mutation {
  releaseAssetLinkUpdate(input: {
    id: "gid://gitlab/Releases::Link/999999",
    name: "Updated name",
    url: "https://example.com/updated/url",
    directAssetPath: "/updated/path",
    linkType: PACKAGE,
  }) {
    link {
      id
      name
      url
      directAssetUrl
      linkType
      external
    },
    errors
  }
}

Response:

{
  "data": {
    "releaseAssetLinkUpdate": 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": [
        "releaseAssetLinkUpdate"
      ]
    }
  ]
}
When a validation error occurs

In this example, another link associated to the parent release already is named "Link 1".

Query:

mutation {
  releaseAssetLinkUpdate(input: {
    id: "gid://gitlab/Releases::Link/186",
    name: "Link 1",
    url: "https://example.com/updated/url",
    directAssetPath: "/updated/path",
    linkType: PACKAGE,
  }) {
    link {
      id
      name
      url
      directAssetUrl
      linkType
      external
    },
    errors
  }
}

Response:

{
  "data": {
    "releaseAssetLinkUpdate": {
      "link": null,
      "errors": [
        "Name has already been taken"
      ]
    }
  }
}

Permissions

Permissions for this endpoint mirror the existing REST API update endpoint.

Edited by Nathan Friend

Merge request reports