Commit f7447302 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'add_boards_url' into 'master'

Expose web_url and web_path board fields

See merge request gitlab-org/gitlab!50947
parents 86a789cd 1d2e4ddb
......@@ -7,6 +7,8 @@ module Types
accepts ::Board
authorize :read_board
present_using BoardPresenter
field :id, type: GraphQL::ID_TYPE, null: false,
description: 'ID (global ID) of the board'
field :name, type: GraphQL::STRING_TYPE, null: true,
......@@ -24,6 +26,12 @@ module Types
description: 'Lists of the board',
resolver: Resolvers::BoardListsResolver,
extras: [:lookahead]
field :web_path, GraphQL::STRING_TYPE, null: false,
description: 'Web path of the board.'
field :web_url, GraphQL::STRING_TYPE, null: false,
description: 'Web URL of the board.'
end
end
......
# frozen_string_literal: true
class BoardPresenter < Gitlab::View::Presenter::Delegated
presents :board
end
---
title: Exposed web_path and web_url fields in Board's GraphQL API
merge_request: 50947
author:
type: added
......@@ -1380,6 +1380,16 @@ type Board {
"""
name: String
"""
Web path of the board.
"""
webPath: String!
"""
Web URL of the board.
"""
webUrl: String!
"""
Weight of the board
"""
......
......@@ -3637,6 +3637,42 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "webPath",
"description": "Web path of the board.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "webUrl",
"description": "Web URL of the board.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "weight",
"description": "Weight of the board",
......@@ -252,6 +252,8 @@ Represents a project or group board.
| `lists` | BoardListConnection | Lists of the board |
| `milestone` | Milestone | The board milestone |
| `name` | String | Name of the board |
| `webPath` | String! | Web path of the board. |
| `webUrl` | String! | Web URL of the board. |
| `weight` | Int | Weight of the board |
### BoardEpic
......
......@@ -18,6 +18,8 @@ module Gitlab
def build(object, **options)
# Objects are sometimes wrapped in a BatchLoader instance
case object.itself
when Board
board_url(object, **options)
when ::Ci::Build
instance.project_job_url(object.project, object, **options)
when Commit
......@@ -52,6 +54,14 @@ module Gitlab
end
# rubocop:enable Metrics/CyclomaticComplexity
def board_url(board, **options)
if board.project_board?
instance.project_board_url(board.resource_parent, board, **options)
else
instance.group_board_url(board.resource_parent, board, **options)
end
end
def commit_url(commit, **options)
return '' unless commit.project
......
......@@ -31,4 +31,8 @@ FactoryBot.define do
board.lists.create!(list_type: :closed)
end
end
factory :group_board, parent: :board do
group
end
end
......@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Board'] do
specify { expect(described_class).to require_graphql_authorizations(:read_board) }
it 'has specific fields' do
expected_fields = %w[id name]
expected_fields = %w[id name web_url web_path]
expect(described_class).to include_graphql_fields(*expected_fields)
end
......
......@@ -18,6 +18,8 @@ RSpec.describe Gitlab::UrlBuilder do
where(:factory, :path_generator) do
:project | ->(project) { "/#{project.full_path}" }
:board | ->(board) { "/#{board.project.full_path}/-/boards/#{board.id}" }
:group_board | ->(board) { "/groups/#{board.group.full_path}/-/boards/#{board.id}" }
:commit | ->(commit) { "/#{commit.project.full_path}/-/commit/#{commit.id}" }
:issue | ->(issue) { "/#{issue.project.full_path}/-/issues/#{issue.iid}" }
:merge_request | ->(merge_request) { "/#{merge_request.project.full_path}/-/merge_requests/#{merge_request.iid}" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment