Commit 09caff58 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'issue_31913' into 'master'

Expose 'subscribed' for epics in GraphQL

See merge request gitlab-org/gitlab!18607
parents 5fee3ef6 8d4c9ea1
......@@ -211,6 +211,7 @@ The API can be explored interactively using the [GraphiQL IDE](../index.md#graph
| `relativePosition` | Int | The relative position of the epic in the Epic tree |
| `relationPath` | String | |
| `reference` | String! | |
| `subscribed` | Boolean! | Boolean flag for whether the currently logged in user is subscribed to this epic |
### EpicIssue
......
......@@ -58,6 +58,12 @@ module Types
argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false # rubocop:disable Graphql/Descriptions
end
field :subscribed, GraphQL::BOOLEAN_TYPE,
method: :subscribed?,
null: false,
complexity: 5,
description: 'Boolean flag for whether the currently logged in user is subscribed to this epic'
field :issues, # rubocop:disable Graphql/Descriptions
Types::EpicIssueType.connection_type,
null: true,
......
......@@ -35,13 +35,17 @@ class EpicPresenter < Gitlab::View::Presenter::Delegated
end
end
def subscribed?
epic.subscribed?(current_user)
end
private
def initial_data
{
labels: epic.labels,
participants: participants,
subscribed: epic.subscribed?(current_user)
subscribed: subscribed?
}
end
......
---
title: Expose subscribed attribute for Epics in GraphQL
merge_request: 18607
author:
type: added
......@@ -10,7 +10,7 @@ describe GitlabSchema.types['Epic'] do
due_date due_date_is_fixed due_date_fixed due_date_from_milestones
closed_at created_at updated_at children has_children has_issues
web_path web_url relation_path reference issues
user_permissions notes discussions relative_position
user_permissions notes discussions relative_position subscribed
]
end
......@@ -21,4 +21,6 @@ describe GitlabSchema.types['Epic'] do
it { expect(described_class).to require_graphql_authorizations(:read_epic) }
it { expect(described_class).to have_graphql_fields(fields) }
it { is_expected.to have_graphql_field(:subscribed, complexity: 5) }
end
......@@ -7,6 +7,6 @@ describe GitlabSchema.types['DiffPosition'] do
:new_path, :position_type, :old_line, :new_line, :x, :y,
:width, :height]
is_expected.to have_graphql_field(*expected_fields)
is_expected.to have_graphql_fields(*expected_fields)
end
end
......@@ -28,9 +28,15 @@ RSpec::Matchers.define :have_graphql_fields do |*expected|
end
end
RSpec::Matchers.define :have_graphql_field do |field_name|
RSpec::Matchers.define :have_graphql_field do |field_name, args = {}|
match do |kls|
expect(kls.fields.keys).to include(GraphqlHelpers.fieldnamerize(field_name))
field = kls.fields[GraphqlHelpers.fieldnamerize(field_name)]
expect(field).to be_present
args.each do |argument, value|
expect(field.send(argument)).to eq(value)
end
end
end
......
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