From 388e63b015b95042498bd12440543fd3052f74e6 Mon Sep 17 00:00:00 2001 From: Niklas <mc.taucher2003@gmail.com> Date: Tue, 23 Aug 2022 12:56:39 +0000 Subject: [PATCH] Add external_url field to Environment GraphQL Type Changelog: added --- app/graphql/types/environment_type.rb | 3 +++ doc/api/graphql/reference/index.md | 1 + spec/graphql/types/environment_type_spec.rb | 9 +++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index 994be0e5f5aee..403c4015218cc 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 698412c470df0..48a559e8ce4da 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 16859394978e2..f652ba2a47061 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 %( -- GitLab