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 ...@@ -7,6 +7,8 @@ module Types
accepts ::Board accepts ::Board
authorize :read_board authorize :read_board
present_using BoardPresenter
field :id, type: GraphQL::ID_TYPE, null: false, field :id, type: GraphQL::ID_TYPE, null: false,
description: 'ID (global ID) of the board' description: 'ID (global ID) of the board'
field :name, type: GraphQL::STRING_TYPE, null: true, field :name, type: GraphQL::STRING_TYPE, null: true,
...@@ -24,6 +26,12 @@ module Types ...@@ -24,6 +26,12 @@ module Types
description: 'Lists of the board', description: 'Lists of the board',
resolver: Resolvers::BoardListsResolver, resolver: Resolvers::BoardListsResolver,
extras: [:lookahead] 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
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 { ...@@ -1380,6 +1380,16 @@ type Board {
""" """
name: String name: String
"""
Web path of the board.
"""
webPath: String!
"""
Web URL of the board.
"""
webUrl: String!
""" """
Weight of the board Weight of the board
""" """
......
...@@ -3637,6 +3637,42 @@ ...@@ -3637,6 +3637,42 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "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", "name": "weight",
"description": "Weight of the board", "description": "Weight of the board",
...@@ -252,6 +252,8 @@ Represents a project or group board. ...@@ -252,6 +252,8 @@ Represents a project or group board.
| `lists` | BoardListConnection | Lists of the board | | `lists` | BoardListConnection | Lists of the board |
| `milestone` | Milestone | The board milestone | | `milestone` | Milestone | The board milestone |
| `name` | String | Name of the board | | `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 | | `weight` | Int | Weight of the board |
### BoardEpic ### BoardEpic
......
...@@ -18,6 +18,8 @@ module Gitlab ...@@ -18,6 +18,8 @@ module Gitlab
def build(object, **options) def build(object, **options)
# Objects are sometimes wrapped in a BatchLoader instance # Objects are sometimes wrapped in a BatchLoader instance
case object.itself case object.itself
when Board
board_url(object, **options)
when ::Ci::Build when ::Ci::Build
instance.project_job_url(object.project, object, **options) instance.project_job_url(object.project, object, **options)
when Commit when Commit
...@@ -52,6 +54,14 @@ module Gitlab ...@@ -52,6 +54,14 @@ module Gitlab
end end
# rubocop:enable Metrics/CyclomaticComplexity # 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) def commit_url(commit, **options)
return '' unless commit.project return '' unless commit.project
......
...@@ -31,4 +31,8 @@ FactoryBot.define do ...@@ -31,4 +31,8 @@ FactoryBot.define do
board.lists.create!(list_type: :closed) board.lists.create!(list_type: :closed)
end end
end end
factory :group_board, parent: :board do
group
end
end end
...@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Board'] do ...@@ -8,7 +8,7 @@ RSpec.describe GitlabSchema.types['Board'] do
specify { expect(described_class).to require_graphql_authorizations(:read_board) } specify { expect(described_class).to require_graphql_authorizations(:read_board) }
it 'has specific fields' do 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) expect(described_class).to include_graphql_fields(*expected_fields)
end end
......
...@@ -18,6 +18,8 @@ RSpec.describe Gitlab::UrlBuilder do ...@@ -18,6 +18,8 @@ RSpec.describe Gitlab::UrlBuilder do
where(:factory, :path_generator) do where(:factory, :path_generator) do
:project | ->(project) { "/#{project.full_path}" } :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}" } :commit | ->(commit) { "/#{commit.project.full_path}/-/commit/#{commit.id}" }
:issue | ->(issue) { "/#{issue.project.full_path}/-/issues/#{issue.iid}" } :issue | ->(issue) { "/#{issue.project.full_path}/-/issues/#{issue.iid}" }
:merge_request | ->(merge_request) { "/#{merge_request.project.full_path}/-/merge_requests/#{merge_request.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