diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index 994be0e5f5aeed90275b61a4ff0ab0673cb41e7e..403c4015218cc8b311069cdee4b86f02bf9e1ff5 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -21,6 +21,9 @@ class EnvironmentType < BaseObject field :path, GraphQL::Types::String, null: false, description: 'Path to the environment.' + field :external_url, GraphQL::Types::String, null: true, + description: 'External URL of the environment.' + field :metrics_dashboard, Types::Metrics::DashboardType, null: true, description: 'Metrics dashboard schema for the environment.', resolver: Resolvers::Metrics::DashboardResolver diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 698412c470df0b2018ab2390e3287f5183b0b60f..48a559e8ce4dab45344bd8592328206c024fb2e8 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -11457,6 +11457,7 @@ Describes where code is deployed for a project. | Name | Type | Description | | ---- | ---- | ----------- | +| <a id="environmentexternalurl"></a>`externalUrl` | [`String`](#string) | External URL of the environment. | | <a id="environmentid"></a>`id` | [`ID!`](#id) | ID of the environment. | | <a id="environmentlatestopenedmostseverealert"></a>`latestOpenedMostSevereAlert` | [`AlertManagementAlert`](#alertmanagementalert) | Most severe open alert for the environment. If multiple alerts have equal severity, the most recent is returned. | | <a id="environmentname"></a>`name` | [`String!`](#string) | Human-readable name of the environment. | diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index 16859394978e22b60b38d38f3fb79d3a5c0bb0d9..f652ba2a47061449ecf3d8358fe271afd58a00db 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -7,7 +7,7 @@ it 'has the expected fields' do expected_fields = %w[ - name id state metrics_dashboard latest_opened_most_severe_alert path deployments + name id state metrics_dashboard latest_opened_most_severe_alert path external_url deployments ] expect(described_class).to have_graphql_fields(*expected_fields) @@ -17,7 +17,7 @@ context 'when there is an environment' do let_it_be(:project) { create(:project) } - let_it_be(:environment) { create(:environment, project: project) } + let_it_be(:environment) { create(:environment, project: project, external_url: 'https://gitlab.com') } let_it_be(:user) { create(:user) } subject { GitlabSchema.execute(query, context: { current_user: user }).as_json } @@ -29,6 +29,7 @@ environment(name: "#{environment.name}") { name path + externalUrl state } } @@ -50,6 +51,10 @@ ) end + it 'returns the external url of the environment' do + expect(subject['data']['project']['environment']['externalUrl']).to eq(environment.external_url) + end + context 'when query alert data for the environment' do let_it_be(:query) do %(