diff options
Diffstat (limited to 'app/graphql')
121 files changed, 982 insertions, 585 deletions
diff --git a/app/graphql/mutations/alert_management/base.rb b/app/graphql/mutations/alert_management/base.rb index 3a57cb9670d..86908c1449c 100644 --- a/app/graphql/mutations/alert_management/base.rb +++ b/app/graphql/mutations/alert_management/base.rb @@ -21,7 +21,7 @@ module Mutations field :todo, Types::TodoType, null: true, - description: "The todo after mutation." + description: "The to-do item after mutation." field :issue, Types::IssueType, diff --git a/app/graphql/mutations/alert_management/http_integration/create.rb b/app/graphql/mutations/alert_management/http_integration/create.rb index ff165d7f302..2d7bffb4333 100644 --- a/app/graphql/mutations/alert_management/http_integration/create.rb +++ b/app/graphql/mutations/alert_management/http_integration/create.rb @@ -4,7 +4,7 @@ module Mutations module AlertManagement module HttpIntegration class Create < HttpIntegrationBase - include ResolvesProject + include FindsProject graphql_name 'HttpIntegrationCreate' @@ -21,27 +21,14 @@ module Mutations description: 'Whether the integration is receiving alerts.' def resolve(args) - @project = authorized_find!(full_path: args[:project_path]) + project = authorized_find!(args[:project_path]) response ::AlertManagement::HttpIntegrations::CreateService.new( project, current_user, - http_integration_params(args) + http_integration_params(project, args) ).execute end - - private - - attr_reader :project - - def find_object(full_path:) - resolve_project(full_path: full_path) - end - - # overriden in EE - def http_integration_params(args) - args.slice(:name, :active) - end end end end diff --git a/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb b/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb index 147df982bec..e33b7bb399a 100644 --- a/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb +++ b/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb @@ -23,7 +23,14 @@ module Mutations errors: result.errors } end + + # overriden in EE + def http_integration_params(_project, args) + args.slice(:name, :active) + end end end end end + +Mutations::AlertManagement::HttpIntegration::HttpIntegrationBase.prepend_if_ee('::EE::Mutations::AlertManagement::HttpIntegration::HttpIntegrationBase') diff --git a/app/graphql/mutations/alert_management/http_integration/update.rb b/app/graphql/mutations/alert_management/http_integration/update.rb index 431fccaa5e5..b1e4ce841ee 100644 --- a/app/graphql/mutations/alert_management/http_integration/update.rb +++ b/app/graphql/mutations/alert_management/http_integration/update.rb @@ -24,10 +24,12 @@ module Mutations response ::AlertManagement::HttpIntegrations::UpdateService.new( integration, current_user, - args.slice(:name, :active) + http_integration_params(integration.project, args) ).execute end end end end end + +Mutations::AlertManagement::HttpIntegration::Update.prepend_if_ee('::EE::Mutations::AlertManagement::HttpIntegration::Update') diff --git a/app/graphql/mutations/alert_management/prometheus_integration/create.rb b/app/graphql/mutations/alert_management/prometheus_integration/create.rb index c676cde90b4..87e6bc46937 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/create.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/create.rb @@ -4,7 +4,7 @@ module Mutations module AlertManagement module PrometheusIntegration class Create < PrometheusIntegrationBase - include ResolvesProject + include FindsProject graphql_name 'PrometheusIntegrationCreate' @@ -21,7 +21,7 @@ module Mutations description: 'Endpoint at which prometheus can be queried.' def resolve(args) - project = authorized_find!(full_path: args[:project_path]) + project = authorized_find!(args[:project_path]) return integration_exists if project.prometheus_service @@ -37,10 +37,6 @@ module Mutations private - def find_object(full_path:) - resolve_project(full_path: full_path) - end - def integration_exists response(nil, message: _('Multiple Prometheus integrations are not supported')) end diff --git a/app/graphql/mutations/branches/create.rb b/app/graphql/mutations/branches/create.rb index 9fe9bef5403..6354976f1ea 100644 --- a/app/graphql/mutations/branches/create.rb +++ b/app/graphql/mutations/branches/create.rb @@ -3,7 +3,7 @@ module Mutations module Branches class Create < BaseMutation - include ResolvesProject + include FindsProject graphql_name 'CreateBranch' @@ -28,7 +28,7 @@ module Mutations authorize :push_code def resolve(project_path:, name:, ref:) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) context.scoped_set!(:branch_project, project) @@ -40,12 +40,6 @@ module Mutations errors: Array.wrap(result[:message]) } end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end end end end diff --git a/app/graphql/mutations/commits/create.rb b/app/graphql/mutations/commits/create.rb index ae14401558b..84933fee5d2 100644 --- a/app/graphql/mutations/commits/create.rb +++ b/app/graphql/mutations/commits/create.rb @@ -3,7 +3,7 @@ module Mutations module Commits class Create < BaseMutation - include ResolvesProject + include FindsProject graphql_name 'CommitCreate' @@ -37,7 +37,7 @@ module Mutations authorize :push_code def resolve(project_path:, branch:, message:, actions:, **args) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) attributes = { commit_message: message, @@ -53,12 +53,6 @@ module Mutations errors: Array.wrap(result[:message]) } end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end end end end diff --git a/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb b/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb new file mode 100644 index 00000000000..2d4983f0d6e --- /dev/null +++ b/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Mutations + # This concern can be mixed into a mutation to provide support for spam checking, + # and optionally support the workflow to allow clients to display and solve CAPTCHAs. + module CanMutateSpammable + extend ActiveSupport::Concern + + # NOTE: The arguments and fields are intentionally named with 'captcha' instead of 'recaptcha', + # so that they can be applied to future alternative CAPTCHA implementations other than + # reCAPTCHA (e.g. FriendlyCaptcha) without having to change the names and descriptions in the API. + included do + argument :captcha_response, GraphQL::STRING_TYPE, + required: false, + description: 'A valid CAPTCHA response value obtained by using the provided captchaSiteKey with a CAPTCHA API to present a challenge to be solved on the client. Required to resubmit if the previous operation returned "NeedsCaptchaResponse: true".' + + argument :spam_log_id, GraphQL::INT_TYPE, + required: false, + description: 'The spam log ID which must be passed along with a valid CAPTCHA response for the operation to be completed. Required to resubmit if the previous operation returned "NeedsCaptchaResponse: true".' + + field :spam, + GraphQL::BOOLEAN_TYPE, + null: true, + description: 'Indicates whether the operation was detected as definite spam. There is no option to resubmit the request with a CAPTCHA response.' + + field :needs_captcha_response, + GraphQL::BOOLEAN_TYPE, + null: true, + description: 'Indicates whether the operation was detected as possible spam and not completed. If CAPTCHA is enabled, the request must be resubmitted with a valid CAPTCHA response and spam_log_id included for the operation to be completed. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' + + field :spam_log_id, + GraphQL::INT_TYPE, + null: true, + description: 'The spam log ID which must be passed along with a valid CAPTCHA response for an operation to be completed. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' + + field :captcha_site_key, + GraphQL::STRING_TYPE, + null: true, + description: 'The CAPTCHA site key which must be used to render a challenge for the user to solve to obtain a valid captchaResponse value. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' + end + + private + + # additional_spam_params -> hash + # + # Used from a spammable mutation's #resolve method to generate + # the required additional spam/recaptcha params which must be merged into the params + # passed to the constructor of a service, where they can then be used in the service + # to perform spam checking via SpamActionService. + # + # Also accesses the #context of the mutation's Resolver superclass to obtain the request. + # + # Example: + # + # existing_args.merge!(additional_spam_params) + def additional_spam_params + { + api: true, + request: context[:request] + } + end + + # with_spam_action_fields(spammable) { {other_fields: true} } -> hash + # + # Takes a Spammable and a block as arguments. + # + # The block passed should be a hash, which the spam action fields will be merged into. + def with_spam_action_fields(spammable) + spam_action_fields = { + spam: spammable.spam?, + # NOTE: These fields are intentionally named with 'captcha' instead of 'recaptcha', so + # that they can be applied to future alternative CAPTCHA implementations other than + # reCAPTCHA (such as FriendlyCaptcha) without having to change the response field name + # in the API. + needs_captcha_response: spammable.render_recaptcha?, + spam_log_id: spammable.spam_log&.id, + captcha_site_key: Gitlab::CurrentSettings.recaptcha_site_key + } + + yield.merge(spam_action_fields) + end + end +end diff --git a/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb b/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb index e2b3f4b046f..b8ef675c3d4 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb @@ -9,11 +9,11 @@ module Mutations included do argument :project_path, GraphQL::ID_TYPE, required: false, - description: 'The project full path the resource is associated with.' + description: 'Full path of the project with which the resource is associated.' argument :group_path, GraphQL::ID_TYPE, required: false, - description: 'The group full path the resource is associated with.' + description: 'Full path of the group with which the resource is associated.' end def ready?(**args) diff --git a/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb b/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb deleted file mode 100644 index e5df8565618..00000000000 --- a/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module SpammableMutationFields - extend ActiveSupport::Concern - - included do - field :spam, - GraphQL::BOOLEAN_TYPE, - null: true, - description: 'Indicates whether the operation returns a record detected as spam.' - end - - def with_spam_params(&block) - request = Feature.enabled?(:snippet_spam) ? context[:request] : nil - - yield.merge({ api: true, request: request }) - end - - def with_spam_fields(spammable, &block) - { spam: spammable.spam? }.merge!(yield) - end - end -end diff --git a/app/graphql/mutations/container_expiration_policies/update.rb b/app/graphql/mutations/container_expiration_policies/update.rb index 37cf2fa6bf3..f61d852bb6c 100644 --- a/app/graphql/mutations/container_expiration_policies/update.rb +++ b/app/graphql/mutations/container_expiration_policies/update.rb @@ -3,7 +3,7 @@ module Mutations module ContainerExpirationPolicies class Update < Mutations::BaseMutation - include ResolvesProject + include FindsProject graphql_name 'UpdateContainerExpirationPolicy' @@ -50,7 +50,7 @@ module Mutations description: 'The container expiration policy after mutation.' def resolve(project_path:, **args) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) result = ::ContainerExpirationPolicies::UpdateService .new(container: project, current_user: current_user, params: args) @@ -61,12 +61,6 @@ module Mutations errors: result.errors } end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end end end end diff --git a/app/graphql/mutations/discussions/toggle_resolve.rb b/app/graphql/mutations/discussions/toggle_resolve.rb index c9834c946b2..6639252ec67 100644 --- a/app/graphql/mutations/discussions/toggle_resolve.rb +++ b/app/graphql/mutations/discussions/toggle_resolve.rb @@ -69,7 +69,7 @@ module Mutations end def unresolve!(discussion) - discussion.unresolve! + ::Discussions::UnresolveService.new(discussion, current_user).execute end end end diff --git a/app/graphql/mutations/issues/create.rb b/app/graphql/mutations/issues/create.rb index 18b80ff1736..37fddd92832 100644 --- a/app/graphql/mutations/issues/create.rb +++ b/app/graphql/mutations/issues/create.rb @@ -3,7 +3,7 @@ module Mutations module Issues class Create < BaseMutation - include ResolvesProject + include FindsProject graphql_name 'CreateIssue' authorize :create_issue @@ -70,7 +70,7 @@ module Mutations end def resolve(project_path:, **attributes) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) params = build_create_issue_params(attributes.merge(author_id: current_user.id)) issue = ::Issues::CreateService.new(project, current_user, params).execute @@ -98,10 +98,6 @@ module Mutations def mutually_exclusive_label_args [:labels, :label_ids] end - - def find_object(full_path:) - resolve_project(full_path: full_path) - end end end end diff --git a/app/graphql/mutations/jira_import/import_users.rb b/app/graphql/mutations/jira_import/import_users.rb index 616ef390657..af2bb18161f 100644 --- a/app/graphql/mutations/jira_import/import_users.rb +++ b/app/graphql/mutations/jira_import/import_users.rb @@ -3,10 +3,12 @@ module Mutations module JiraImport class ImportUsers < BaseMutation - include ResolvesProject + include FindsProject graphql_name 'JiraImportUsers' + authorize :admin_project + field :jira_users, [Types::JiraUserType], null: true, @@ -20,7 +22,7 @@ module Mutations description: 'The index of the record the import should started at, default 0 (50 records returned).' def resolve(project_path:, start_at: 0) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) service_response = ::JiraImport::UsersImporter.new(context[:current_user], project, start_at.to_i).execute @@ -29,16 +31,6 @@ module Mutations errors: service_response.errors } end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end - - def authorized_resource?(project) - Ability.allowed?(context[:current_user], :admin_project, project) - end end end end diff --git a/app/graphql/mutations/jira_import/start.rb b/app/graphql/mutations/jira_import/start.rb index 3d50ebde13a..e31aaf53a09 100644 --- a/app/graphql/mutations/jira_import/start.rb +++ b/app/graphql/mutations/jira_import/start.rb @@ -3,10 +3,12 @@ module Mutations module JiraImport class Start < BaseMutation - include ResolvesProject + include FindsProject graphql_name 'JiraImportStart' + authorize :admin_project + field :jira_import, Types::JiraImportType, null: true, @@ -27,7 +29,7 @@ module Mutations description: 'The mapping of Jira to GitLab users.' def resolve(project_path:, jira_project_key:, users_mapping:) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) mapping = users_mapping.to_ary.map { |map| map.to_hash } service_response = ::JiraImport::StartImportService @@ -40,16 +42,6 @@ module Mutations errors: service_response.errors } end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end - - def authorized_resource?(project) - Ability.allowed?(context[:current_user], :admin_project, project) - end end end end diff --git a/app/graphql/mutations/merge_requests/create.rb b/app/graphql/mutations/merge_requests/create.rb index 64fa8417e50..9ac8f70be95 100644 --- a/app/graphql/mutations/merge_requests/create.rb +++ b/app/graphql/mutations/merge_requests/create.rb @@ -3,7 +3,7 @@ module Mutations module MergeRequests class Create < BaseMutation - include ResolvesProject + include FindsProject graphql_name 'MergeRequestCreate' @@ -39,7 +39,7 @@ module Mutations authorize :create_merge_request_from def resolve(project_path:, **attributes) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) params = attributes.merge(author_id: current_user.id) merge_request = ::MergeRequests::CreateService.new(project, current_user, params).execute @@ -49,12 +49,6 @@ module Mutations errors: errors_on_object(merge_request) } end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end end end end diff --git a/app/graphql/mutations/merge_requests/reviewer_rereview.rb b/app/graphql/mutations/merge_requests/reviewer_rereview.rb new file mode 100644 index 00000000000..f6f4881654e --- /dev/null +++ b/app/graphql/mutations/merge_requests/reviewer_rereview.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Mutations + module MergeRequests + class ReviewerRereview < Base + graphql_name 'MergeRequestReviewerRereview' + + argument :user_id, ::Types::GlobalIDType[::User], + loads: Types::UserType, + required: true, + description: <<~DESC + The user ID for the user that has been requested for a new review. + DESC + + def resolve(project_path:, iid:, user:) + merge_request = authorized_find!(project_path: project_path, iid: iid) + + result = ::MergeRequests::RequestReviewService.new(merge_request.project, current_user).execute(merge_request, user) + + { + merge_request: merge_request, + errors: Array(result[:message]) + } + end + end + end +end diff --git a/app/graphql/mutations/releases/base.rb b/app/graphql/mutations/releases/base.rb index dd1724fe320..610e9cd9cde 100644 --- a/app/graphql/mutations/releases/base.rb +++ b/app/graphql/mutations/releases/base.rb @@ -3,17 +3,11 @@ module Mutations module Releases class Base < BaseMutation - include ResolvesProject + include FindsProject argument :project_path, GraphQL::ID_TYPE, required: true, description: 'Full path of the project the release is associated with.' - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end end end end diff --git a/app/graphql/mutations/releases/create.rb b/app/graphql/mutations/releases/create.rb index 91ac256033e..914c1302094 100644 --- a/app/graphql/mutations/releases/create.rb +++ b/app/graphql/mutations/releases/create.rb @@ -41,7 +41,7 @@ module Mutations authorize :create_release def resolve(project_path:, assets: nil, **scalars) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) params = { **scalars, diff --git a/app/graphql/mutations/releases/delete.rb b/app/graphql/mutations/releases/delete.rb index e887b702cce..020c9133b58 100644 --- a/app/graphql/mutations/releases/delete.rb +++ b/app/graphql/mutations/releases/delete.rb @@ -17,7 +17,7 @@ module Mutations authorize :destroy_release def resolve(project_path:, tag:) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) params = { tag: tag }.with_indifferent_access diff --git a/app/graphql/mutations/releases/update.rb b/app/graphql/mutations/releases/update.rb index dff743254bd..35f2a7b3d4b 100644 --- a/app/graphql/mutations/releases/update.rb +++ b/app/graphql/mutations/releases/update.rb @@ -47,7 +47,7 @@ module Mutations end def resolve(project_path:, **scalars) - project = authorized_find!(full_path: project_path) + project = authorized_find!(project_path) params = scalars.with_indifferent_access diff --git a/app/graphql/mutations/security/ci_configuration/configure_sast.rb b/app/graphql/mutations/security/ci_configuration/configure_sast.rb new file mode 100644 index 00000000000..e4a3f815396 --- /dev/null +++ b/app/graphql/mutations/security/ci_configuration/configure_sast.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Mutations + module Security + module CiConfiguration + class ConfigureSast < BaseMutation + include FindsProject + + graphql_name 'ConfigureSast' + + argument :project_path, GraphQL::ID_TYPE, + required: true, + description: 'Full path of the project.' + + argument :configuration, ::Types::CiConfiguration::Sast::InputType, + required: true, + description: 'SAST CI configuration for the project.' + + field :status, GraphQL::STRING_TYPE, null: false, + description: 'Status of creating the commit for the supplied SAST CI configuration.' + + field :success_path, GraphQL::STRING_TYPE, null: true, + description: 'Redirect path to use when the response is successful.' + + authorize :push_code + + def resolve(project_path:, configuration:) + project = authorized_find!(project_path) + + result = ::Security::CiConfiguration::SastCreateService.new(project, current_user, configuration).execute + prepare_response(result) + end + + private + + def prepare_response(result) + { + status: result[:status], + success_path: result[:success_path], + errors: Array(result[:errors]) + } + end + end + end + end +end diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb index b4485e28c5a..73eac9f0f3b 100644 --- a/app/graphql/mutations/snippets/create.rb +++ b/app/graphql/mutations/snippets/create.rb @@ -3,7 +3,8 @@ module Mutations module Snippets class Create < BaseMutation - include SpammableMutationFields + include ServiceCompatibility + include CanMutateSpammable authorize :create_snippet @@ -45,18 +46,17 @@ module Mutations authorize!(:global) end - service_response = ::Snippets::CreateService.new(project, - current_user, - create_params(args)).execute + process_args_for_params!(args) - snippet = service_response.payload[:snippet] + service_response = ::Snippets::CreateService.new(project, current_user, args).execute # Only when the user is not an api user and the operation was successful if !api_user? && service_response.success? ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user) end - with_spam_fields(snippet) do + snippet = service_response.payload[:snippet] + with_spam_action_fields(snippet) do { snippet: service_response.success? ? snippet : nil, errors: errors_on_object(snippet) @@ -70,18 +70,25 @@ module Mutations Project.find_by_full_path(full_path) end - def create_params(args) - with_spam_params do - args.tap do |create_args| - # We need to rename `blob_actions` into `snippet_actions` because - # it's the expected key param - create_args[:snippet_actions] = create_args.delete(:blob_actions)&.map(&:to_h) - - # We need to rename `uploaded_files` into `files` because - # it's the expected key param - create_args[:files] = create_args.delete(:uploaded_files) - end + # process_args_for_params!(args) -> nil + # + # Modifies/adds/deletes mutation resolve args as necessary to be passed as params to service layer. + def process_args_for_params!(args) + convert_blob_actions_to_snippet_actions!(args) + + # We need to rename `uploaded_files` into `files` because + # it's the expected key param + args[:files] = args.delete(:uploaded_files) + + if Feature.enabled?(:snippet_spam) + args.merge!(additional_spam_params) + else + args[:disable_spam_action_service] = true end + + # Return nil to make it explicit that this method is mutating the args parameter, and that + # the return value is not relevant and is not to be used. + nil end end end diff --git a/app/graphql/mutations/snippets/service_compatibility.rb b/app/graphql/mutations/snippets/service_compatibility.rb new file mode 100644 index 00000000000..0e7ee5d78bf --- /dev/null +++ b/app/graphql/mutations/snippets/service_compatibility.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Mutations + module Snippets + # Translates graphql mutation field params to be compatible with those expected by the service layer + module ServiceCompatibility + extend ActiveSupport::Concern + + # convert_blob_actions_to_snippet_actions!(args) -> nil + # + # Converts the blob_actions mutation argument into the + # snippet_actions hash which the service layer expects + def convert_blob_actions_to_snippet_actions!(args) + # We need to rename `blob_actions` into `snippet_actions` because + # it's the expected key param + args[:snippet_actions] = args.delete(:blob_actions)&.map(&:to_h) + + # Return nil to make it explicit that this method is mutating the args parameter + nil + end + end + end +end diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb index 930440fbd35..af8e6f384b7 100644 --- a/app/graphql/mutations/snippets/update.rb +++ b/app/graphql/mutations/snippets/update.rb @@ -3,7 +3,8 @@ module Mutations module Snippets class Update < Base - include SpammableMutationFields + include ServiceCompatibility + include CanMutateSpammable graphql_name 'UpdateSnippet' @@ -30,19 +31,23 @@ module Mutations def resolve(id:, **args) snippet = authorized_find!(id: id) - result = ::Snippets::UpdateService.new(snippet.project, - current_user, - update_params(args)).execute(snippet) - snippet = result.payload[:snippet] + process_args_for_params!(args) + + service_response = ::Snippets::UpdateService.new(snippet.project, current_user, args).execute(snippet) + + # TODO: DRY this up - From here down, this is all duplicated with Mutations::Snippets::Create#resolve, except for + # `snippet.reset`, which is required in order to return the object in its non-dirty, unmodified, database state + # See issue here: https://gitlab.com/gitlab-org/gitlab/-/issues/300250 # Only when the user is not an api user and the operation was successful - if !api_user? && result.success? + if !api_user? && service_response.success? ::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user) end - with_spam_fields(snippet) do + snippet = service_response.payload[:snippet] + with_spam_action_fields(snippet) do { - snippet: result.success? ? snippet : snippet.reset, + snippet: service_response.success? ? snippet : snippet.reset, errors: errors_on_object(snippet) } end @@ -50,18 +55,25 @@ module Mutations private - def ability_name - 'update' - end + # process_args_for_params!(args) -> nil + # + # Modifies/adds/deletes mutation resolve args as necessary to be passed as params to service layer. + def process_args_for_params!(args) + convert_blob_actions_to_snippet_actions!(args) - def update_params(args) - with_spam_params do - args.tap do |update_args| - # We need to rename `blob_actions` into `snippet_actions` because - # it's the expected key param - update_args[:snippet_actions] = update_args.delete(:blob_actions)&.map(&:to_h) - end + if Feature.enabled?(:snippet_spam) + args.merge!(additional_spam_params) + else + args[:disable_spam_action_service] = true end + + # Return nil to make it explicit that this method is mutating the args parameter, and that + # the return value is not relevant and is not to be used. + nil + end + + def ability_name + 'update' end end end diff --git a/app/graphql/mutations/todos/create.rb b/app/graphql/mutations/todos/create.rb index 814f7ec4fc4..b6250b0228c 100644 --- a/app/graphql/mutations/todos/create.rb +++ b/app/graphql/mutations/todos/create.rb @@ -14,7 +14,7 @@ module Mutations field :todo, Types::TodoType, null: true, - description: 'The to-do created.' + description: 'The to-do item created.' def resolve(target_id:) id = ::Types::GlobalIDType[Todoable].coerce_isolated_input(target_id) diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb index c8359953567..22a5893d4ec 100644 --- a/app/graphql/mutations/todos/mark_all_done.rb +++ b/app/graphql/mutations/todos/mark_all_done.rb @@ -10,12 +10,12 @@ module Mutations field :updated_ids, [::Types::GlobalIDType[::Todo]], null: false, - deprecated: { reason: 'Use todos', milestone: '13.2' }, - description: 'Ids of the updated todos.' + deprecated: { reason: 'Use to-do items', milestone: '13.2' }, + description: 'IDs of the updated to-do items.' field :todos, [::Types::TodoType], null: false, - description: 'Updated todos.' + description: 'Updated to-do items.' def resolve authorize!(current_user) diff --git a/app/graphql/mutations/todos/mark_done.rb b/app/graphql/mutations/todos/mark_done.rb index 95144abb040..a78cc91da68 100644 --- a/app/graphql/mutations/todos/mark_done.rb +++ b/app/graphql/mutations/todos/mark_done.rb @@ -10,11 +10,11 @@ module Mutations argument :id, ::Types::GlobalIDType[::Todo], required: true, - description: 'The global ID of the todo to mark as done.' + description: 'The global ID of the to-do item to mark as done.' field :todo, Types::TodoType, null: false, - description: 'The requested todo.' + description: 'The requested to-do item.' def resolve(id:) todo = authorized_find!(id: id) diff --git a/app/graphql/mutations/todos/restore.rb b/app/graphql/mutations/todos/restore.rb index e496627aec2..70c33c439c4 100644 --- a/app/graphql/mutations/todos/restore.rb +++ b/app/graphql/mutations/todos/restore.rb @@ -10,11 +10,11 @@ module Mutations argument :id, ::Types::GlobalIDType[::Todo], required: true, - description: 'The global ID of the todo to restore.' + description: 'The global ID of the to-do item to restore.' field :todo, Types::TodoType, null: false, - description: 'The requested todo.' + description: 'The requested to-do item.' def resolve(id:) todo = authorized_find!(id: id) diff --git a/app/graphql/mutations/todos/restore_many.rb b/app/graphql/mutations/todos/restore_many.rb index 9263c1d9afe..dc02ffadada 100644 --- a/app/graphql/mutations/todos/restore_many.rb +++ b/app/graphql/mutations/todos/restore_many.rb @@ -10,16 +10,16 @@ module Mutations argument :ids, [::Types::GlobalIDType[::Todo]], required: true, - description: 'The global IDs of the todos to restore (a maximum of 50 is supported at once).' + description: 'The global IDs of the to-do items to restore (a maximum of 50 is supported at once).' field :updated_ids, [::Types::GlobalIDType[Todo]], null: false, - description: 'The IDs of the updated todo items.', - deprecated: { reason: 'Use todos', milestone: '13.2' } + description: 'The IDs of the updated to-do items.', + deprecated: { reason: 'Use to-do items', milestone: '13.2' } field :todos, [::Types::TodoType], null: false, - description: 'Updated todos.' + description: 'Updated to-do items.' def resolve(ids:) check_update_amount_limit!(ids) @@ -46,7 +46,7 @@ module Mutations end def raise_too_many_todos_requested_error - raise Gitlab::Graphql::Errors::ArgumentError, 'Too many todos requested.' + raise Gitlab::Graphql::Errors::ArgumentError, 'Too many to-do items requested.' end def check_update_amount_limit!(ids) diff --git a/app/graphql/resolvers/base_resolver.rb b/app/graphql/resolvers/base_resolver.rb index 539e37db1c2..5db618254cb 100644 --- a/app/graphql/resolvers/base_resolver.rb +++ b/app/graphql/resolvers/base_resolver.rb @@ -118,7 +118,7 @@ module Resolvers end def offset_pagination(relation) - ::Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection.new(relation) + ::Gitlab::Graphql::Pagination::OffsetPaginatedRelation.new(relation) end override :object diff --git a/app/graphql/resolvers/package_details_resolver.rb b/app/graphql/resolvers/package_details_resolver.rb index dcf4430e55f..e688e34599a 100644 --- a/app/graphql/resolvers/package_details_resolver.rb +++ b/app/graphql/resolvers/package_details_resolver.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true module Resolvers - # No return types defined because they can be different. - # rubocop: disable Graphql/ResolverType class PackageDetailsResolver < BaseResolver + type ::Types::Packages::PackageType, null: true + argument :id, ::Types::GlobalIDType[::Packages::Package], required: true, description: 'The global ID of the package.' diff --git a/app/graphql/resolvers/packages_resolver.rb b/app/graphql/resolvers/packages_resolver.rb index d19099e94d4..3eeed48ff7e 100644 --- a/app/graphql/resolvers/packages_resolver.rb +++ b/app/graphql/resolvers/packages_resolver.rb @@ -2,7 +2,7 @@ module Resolvers class PackagesResolver < BaseResolver - type Types::Packages::PackageType, null: true + type Types::Packages::PackageType.connection_type, null: true def resolve(**args) return unless packages_available? diff --git a/app/graphql/resolvers/project_merge_requests_resolver.rb b/app/graphql/resolvers/project_merge_requests_resolver.rb index 830649d5e52..21d9afc31ab 100644 --- a/app/graphql/resolvers/project_merge_requests_resolver.rb +++ b/app/graphql/resolvers/project_merge_requests_resolver.rb @@ -6,5 +6,38 @@ module Resolvers accept_assignee accept_author accept_reviewer + + def resolve(**args) + scope = super + + if only_count_is_selected_with_merged_at_filter?(args) && Feature.enabled?(:optimized_merge_request_count_with_merged_at_filter) + MergeRequest::MetricsFinder + .new(current_user, args.merge(target_project: project)) + .execute + else + scope + end + end + + def only_count_is_selected_with_merged_at_filter?(args) + return unless lookahead + + argument_names = args.except(:lookahead, :sort, :merged_before, :merged_after).keys + + # no extra filtering arguments are provided + return unless argument_names.empty? + return unless args[:merged_after] || args[:merged_before] + + # Detecting a specific query pattern: + # mergeRequests(mergedAfter: "X", mergedBefore: "Y") { + # count + # totalTimeToMerge + # } + allowed_selected_fields = [:count, :total_time_to_merge] + selected_fields = lookahead.selections.map(&:field).map(&:original_name) + + # only the allowed_selected_fields are present + (selected_fields - allowed_selected_fields).empty? + end end end diff --git a/app/graphql/resolvers/terraform/states_resolver.rb b/app/graphql/resolvers/terraform/states_resolver.rb index 38b26a948b1..f543eb182e8 100644 --- a/app/graphql/resolvers/terraform/states_resolver.rb +++ b/app/graphql/resolvers/terraform/states_resolver.rb @@ -3,20 +3,20 @@ module Resolvers module Terraform class StatesResolver < BaseResolver - type Types::Terraform::StateType, null: true + type Types::Terraform::StateType.connection_type, null: true alias_method :project, :object - def resolve(**args) - return ::Terraform::State.none unless can_read_terraform_states? - - project.terraform_states.ordered_by_name + when_single do + argument :name, GraphQL::STRING_TYPE, + required: true, + description: 'Name of the Terraform state.' end - private - - def can_read_terraform_states? - current_user.can?(:read_terraform_state, project) + def resolve(**args) + ::Terraform::StatesFinder + .new(project, current_user, params: args) + .execute end end end diff --git a/app/graphql/types/access_level_type.rb b/app/graphql/types/access_level_type.rb index c7f915f5038..21c3669979c 100644 --- a/app/graphql/types/access_level_type.rb +++ b/app/graphql/types/access_level_type.rb @@ -7,11 +7,11 @@ module Types description 'Represents the access level of a relationship between a User and object that it is related to' field :integer_value, GraphQL::INT_TYPE, null: true, - description: 'Integer representation of access level', + description: 'Integer representation of access level.', method: :to_i field :string_value, Types::AccessLevelEnum, null: true, - description: 'String representation of access level', + description: 'String representation of access level.', method: :to_i end end diff --git a/app/graphql/types/admin/analytics/instance_statistics/measurement_type.rb b/app/graphql/types/admin/analytics/instance_statistics/measurement_type.rb index eab42c2b78d..17a5af8d36b 100644 --- a/app/graphql/types/admin/analytics/instance_statistics/measurement_type.rb +++ b/app/graphql/types/admin/analytics/instance_statistics/measurement_type.rb @@ -12,13 +12,13 @@ module Types authorize :read_instance_statistics_measurements field :recorded_at, Types::TimeType, null: true, - description: 'The time the measurement was recorded' + description: 'The time the measurement was recorded.' field :count, GraphQL::INT_TYPE, null: false, - description: 'Object count' + description: 'Object count.' field :identifier, Types::Admin::Analytics::InstanceStatistics::MeasurementIdentifierEnum, null: false, - description: 'The type of objects being measured' + description: 'The type of objects being measured.' end end end diff --git a/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb b/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb index 93dd49b3c38..996300edad3 100644 --- a/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb +++ b/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb @@ -12,17 +12,17 @@ module Types field :completed, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Whether or not the entire queue was processed in time; if not, retrying the same request is safe' + description: 'Whether or not the entire queue was processed in time; if not, retrying the same request is safe.' field :deleted_jobs, GraphQL::INT_TYPE, null: true, - description: 'The number of matching jobs deleted' + description: 'The number of matching jobs deleted.' field :queue_size, GraphQL::INT_TYPE, null: true, - description: 'The queue size after processing' + description: 'The queue size after processing.' end end end diff --git a/app/graphql/types/alert_management/alert_status_counts_type.rb b/app/graphql/types/alert_management/alert_status_counts_type.rb index a84be705445..14a81735fa5 100644 --- a/app/graphql/types/alert_management/alert_status_counts_type.rb +++ b/app/graphql/types/alert_management/alert_status_counts_type.rb @@ -19,12 +19,12 @@ module Types field :open, GraphQL::INT_TYPE, null: true, - description: 'Number of alerts with status TRIGGERED or ACKNOWLEDGED for the project' + description: 'Number of alerts with status TRIGGERED or ACKNOWLEDGED for the project.' field :all, GraphQL::INT_TYPE, null: true, - description: 'Total number of alerts for the project' + description: 'Total number of alerts for the project.' end end end diff --git a/app/graphql/types/alert_management/alert_type.rb b/app/graphql/types/alert_management/alert_type.rb index 623762de208..6b7e7030c1f 100644 --- a/app/graphql/types/alert_management/alert_type.rb +++ b/app/graphql/types/alert_management/alert_type.rb @@ -15,115 +15,115 @@ module Types field :iid, GraphQL::ID_TYPE, null: false, - description: 'Internal ID of the alert' + description: 'Internal ID of the alert.' field :issue_iid, GraphQL::ID_TYPE, null: true, - description: 'Internal ID of the GitLab issue attached to the alert' + description: 'Internal ID of the GitLab issue attached to the alert.' field :title, GraphQL::STRING_TYPE, null: true, - description: 'Title of the alert' + description: 'Title of the alert.' field :description, GraphQL::STRING_TYPE, null: true, - description: 'Description of the alert' + description: 'Description of the alert.' field :severity, AlertManagement::SeverityEnum, null: true, - description: 'Severity of the alert' + description: 'Severity of the alert.' field :status, AlertManagement::StatusEnum, null: true, - description: 'Status of the alert', + description: 'Status of the alert.', method: :status_name field :service, GraphQL::STRING_TYPE, null: true, - description: 'Service the alert came from' + description: 'Service the alert came from.' field :monitoring_tool, GraphQL::STRING_TYPE, null: true, - description: 'Monitoring tool the alert came from' + description: 'Monitoring tool the alert came from.' field :hosts, [GraphQL::STRING_TYPE], null: true, - description: 'List of hosts the alert came from' + description: 'List of hosts the alert came from.' field :started_at, Types::TimeType, null: true, - description: 'Timestamp the alert was raised' + description: 'Timestamp the alert was raised.' field :ended_at, Types::TimeType, null: true, - description: 'Timestamp the alert ended' + description: 'Timestamp the alert ended.' field :environment, Types::EnvironmentType, null: true, - description: 'Environment for the alert' + description: 'Environment for the alert.' field :event_count, GraphQL::INT_TYPE, null: true, - description: 'Number of events of this alert', + description: 'Number of events of this alert.', method: :events field :details, # rubocop:disable Graphql/JSONType GraphQL::Types::JSON, null: true, - description: 'Alert details' + description: 'Alert details.' field :created_at, Types::TimeType, null: true, - description: 'Timestamp the alert was created' + description: 'Timestamp the alert was created.' field :updated_at, Types::TimeType, null: true, - description: 'Timestamp the alert was last updated' + description: 'Timestamp the alert was last updated.' field :assignees, Types::UserType.connection_type, null: true, - description: 'Assignees of the alert' + description: 'Assignees of the alert.' field :metrics_dashboard_url, GraphQL::STRING_TYPE, null: true, - description: 'URL for metrics embed for the alert' + description: 'URL for metrics embed for the alert.' field :runbook, GraphQL::STRING_TYPE, null: true, - description: 'Runbook for the alert as defined in alert details' + description: 'Runbook for the alert as defined in alert details.' field :todos, Types::TodoType.connection_type, null: true, - description: 'Todos of the current user for the alert', + description: 'To-do items of the current user for the alert.', resolver: Resolvers::TodoResolver field :details_url, GraphQL::STRING_TYPE, null: false, - description: 'The URL of the alert detail page' + description: 'The URL of the alert detail page.' field :prometheus_alert, Types::PrometheusAlertType, null: true, - description: 'The alert condition for Prometheus' + description: 'The alert condition for Prometheus.' def notes object.ordered_notes diff --git a/app/graphql/types/alert_management/integration_type.rb b/app/graphql/types/alert_management/integration_type.rb index bf599885584..d26d7348765 100644 --- a/app/graphql/types/alert_management/integration_type.rb +++ b/app/graphql/types/alert_management/integration_type.rb @@ -9,37 +9,37 @@ module Types field :id, GraphQL::ID_TYPE, null: false, - description: 'ID of the integration' + description: 'ID of the integration.' field :type, AlertManagement::IntegrationTypeEnum, null: false, - description: 'Type of integration' + description: 'Type of integration.' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the integration' + description: 'Name of the integration.' field :active, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Whether the endpoint is currently accepting alerts' + description: 'Whether the endpoint is currently accepting alerts.' field :token, GraphQL::STRING_TYPE, null: true, - description: 'Token used to authenticate alert notification requests' + description: 'Token used to authenticate alert notification requests.' field :url, GraphQL::STRING_TYPE, null: true, - description: 'Endpoint which accepts alert notifications' + description: 'Endpoint which accepts alert notifications.' field :api_url, GraphQL::STRING_TYPE, null: true, - description: 'URL at which Prometheus metrics can be queried to populate the metrics dashboard' + description: 'URL at which Prometheus metrics can be queried to populate the metrics dashboard.' definition_methods do def resolve_type(object, context) diff --git a/app/graphql/types/award_emojis/award_emoji_type.rb b/app/graphql/types/award_emojis/award_emoji_type.rb index cd7a2f34ba6..9409304e28f 100644 --- a/app/graphql/types/award_emojis/award_emoji_type.rb +++ b/app/graphql/types/award_emojis/award_emoji_type.rb @@ -13,32 +13,32 @@ module Types field :name, GraphQL::STRING_TYPE, null: false, - description: 'The emoji name' + description: 'The emoji name.' field :description, GraphQL::STRING_TYPE, null: false, - description: 'The emoji description' + description: 'The emoji description.' field :unicode, GraphQL::STRING_TYPE, null: false, - description: 'The emoji in unicode' + description: 'The emoji in Unicode.' field :emoji, GraphQL::STRING_TYPE, null: false, - description: 'The emoji as an icon' + description: 'The emoji as an icon.' field :unicode_version, GraphQL::STRING_TYPE, null: false, - description: 'The unicode version for this emoji' + description: 'The Unicode version for this emoji.' field :user, Types::UserType, null: false, - description: 'The user who awarded the emoji' + description: 'The user who awarded the emoji.' def user Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find diff --git a/app/graphql/types/base_enum.rb b/app/graphql/types/base_enum.rb index cbd45b46dd6..4d470aceca4 100644 --- a/app/graphql/types/base_enum.rb +++ b/app/graphql/types/base_enum.rb @@ -21,7 +21,7 @@ module Types graphql_name(enum_mod.name) if use_name description(enum_mod.description) if use_description - enum_mod.definition.each { |key, content| value(key.to_s.upcase, content) } + enum_mod.definition.each { |key, content| value(key.to_s.upcase, **content) } end def value(*args, **kwargs, &block) diff --git a/app/graphql/types/board_list_type.rb b/app/graphql/types/board_list_type.rb index 7999e77eb30..46b49c5d8a4 100644 --- a/app/graphql/types/board_list_type.rb +++ b/app/graphql/types/board_list_type.rb @@ -9,22 +9,22 @@ module Types description 'Represents a list for an issue board' field :id, GraphQL::ID_TYPE, null: false, - description: 'ID (global ID) of the list' + description: 'ID (global ID) of the list.' field :title, GraphQL::STRING_TYPE, null: false, - description: 'Title of the list' + description: 'Title of the list.' field :list_type, GraphQL::STRING_TYPE, null: false, - description: 'Type of the list' + description: 'Type of the list.' field :position, GraphQL::INT_TYPE, null: true, - description: 'Position of list within the board' + description: 'Position of list within the board.' field :label, Types::LabelType, null: true, - description: 'Label of the list' + description: 'Label of the list.' field :collapsed, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates if list is collapsed for this user' + description: 'Indicates if list is collapsed for this user.' field :issues_count, GraphQL::INT_TYPE, null: true, - description: 'Count of issues in the list' + description: 'Count of issues in the list.' field :issues, ::Types::IssueType.connection_type, null: true, - description: 'Board issues', + description: 'Board issues.', resolver: ::Resolvers::BoardListIssuesResolver def issues_count diff --git a/app/graphql/types/board_type.rb b/app/graphql/types/board_type.rb index f576fd83840..f8bd31d5fa0 100644 --- a/app/graphql/types/board_type.rb +++ b/app/graphql/types/board_type.rb @@ -10,20 +10,20 @@ module Types present_using BoardPresenter 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, - description: 'Name of the board' + description: 'Name of the board.' field :hide_backlog_list, type: GraphQL::BOOLEAN_TYPE, null: true, - description: 'Whether or not backlog list is hidden' + description: 'Whether or not backlog list is hidden.' field :hide_closed_list, type: GraphQL::BOOLEAN_TYPE, null: true, - description: 'Whether or not closed list is hidden' + description: 'Whether or not closed list is hidden.' field :lists, Types::BoardListType.connection_type, null: true, - description: 'Lists of the board', + description: 'Lists of the board.', resolver: Resolvers::BoardListsResolver, extras: [:lookahead] diff --git a/app/graphql/types/boards/board_issue_input_base_type.rb b/app/graphql/types/boards/board_issue_input_base_type.rb index 1187b3352cd..dab1414760b 100644 --- a/app/graphql/types/boards/board_issue_input_base_type.rb +++ b/app/graphql/types/boards/board_issue_input_base_type.rb @@ -6,27 +6,27 @@ module Types class BoardIssueInputBaseType < BaseInputObject argument :label_name, GraphQL::STRING_TYPE.to_list_type, required: false, - description: 'Filter by label name' + description: 'Filter by label name.' argument :milestone_title, GraphQL::STRING_TYPE, required: false, - description: 'Filter by milestone title' + description: 'Filter by milestone title.' argument :assignee_username, GraphQL::STRING_TYPE.to_list_type, required: false, - description: 'Filter by assignee username' + description: 'Filter by assignee username.' argument :author_username, GraphQL::STRING_TYPE, required: false, - description: 'Filter by author username' + description: 'Filter by author username.' argument :release_tag, GraphQL::STRING_TYPE, required: false, - description: 'Filter by release tag' + description: 'Filter by release tag.' argument :my_reaction_emoji, GraphQL::STRING_TYPE, required: false, - description: 'Filter by reaction emoji' + description: 'Filter by reaction emoji.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/boards/board_issue_input_type.rb b/app/graphql/types/boards/board_issue_input_type.rb index 40d065d8ea9..62a402ee724 100644 --- a/app/graphql/types/boards/board_issue_input_type.rb +++ b/app/graphql/types/boards/board_issue_input_type.rb @@ -11,11 +11,11 @@ module Types argument :not, NegatedBoardIssueInputType, required: false, - description: 'List of negated params. Warning: this argument is experimental and a subject to change in future' + description: 'List of negated params. Warning: this argument is experimental and a subject to change in future.' argument :search, GraphQL::STRING_TYPE, required: false, - description: 'Search query for issue title or description' + description: 'Search query for issue title or description.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/branch_type.rb b/app/graphql/types/branch_type.rb index b15038a46de..b788ba79769 100644 --- a/app/graphql/types/branch_type.rb +++ b/app/graphql/types/branch_type.rb @@ -8,11 +8,11 @@ module Types field :name, GraphQL::STRING_TYPE, null: false, - description: 'Name of the branch' + description: 'Name of the branch.' field :commit, Types::CommitType, null: true, resolver: Resolvers::BranchCommitResolver, - description: 'Commit for the branch' + description: 'Commit for the branch.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/ci/analytics_type.rb b/app/graphql/types/ci/analytics_type.rb index c8b12c6a9b8..ba987b133bd 100644 --- a/app/graphql/types/ci/analytics_type.rb +++ b/app/graphql/types/ci/analytics_type.rb @@ -7,27 +7,27 @@ module Types graphql_name 'PipelineAnalytics' field :week_pipelines_totals, [GraphQL::INT_TYPE], null: true, - description: 'Total weekly pipeline count' + description: 'Total weekly pipeline count.' field :week_pipelines_successful, [GraphQL::INT_TYPE], null: true, - description: 'Total weekly successful pipeline count' + description: 'Total weekly successful pipeline count.' field :week_pipelines_labels, [GraphQL::STRING_TYPE], null: true, - description: 'Labels for the weekly pipeline count' + description: 'Labels for the weekly pipeline count.' field :month_pipelines_totals, [GraphQL::INT_TYPE], null: true, - description: 'Total monthly pipeline count' + description: 'Total monthly pipeline count.' field :month_pipelines_successful, [GraphQL::INT_TYPE], null: true, - description: 'Total monthly successful pipeline count' + description: 'Total monthly successful pipeline count.' field :month_pipelines_labels, [GraphQL::STRING_TYPE], null: true, - description: 'Labels for the monthly pipeline count' + description: 'Labels for the monthly pipeline count.' field :year_pipelines_totals, [GraphQL::INT_TYPE], null: true, - description: 'Total yearly pipeline count' + description: 'Total yearly pipeline count.' field :year_pipelines_successful, [GraphQL::INT_TYPE], null: true, - description: 'Total yearly successful pipeline count' + description: 'Total yearly successful pipeline count.' field :year_pipelines_labels, [GraphQL::STRING_TYPE], null: true, - description: 'Labels for the yearly pipeline count' + description: 'Labels for the yearly pipeline count.' field :pipeline_times_values, [GraphQL::INT_TYPE], null: true, - description: 'Pipeline times' + description: 'Pipeline times.' field :pipeline_times_labels, [GraphQL::STRING_TYPE], null: true, - description: 'Pipeline times labels' + description: 'Pipeline times labels.' end end end diff --git a/app/graphql/types/ci/config/config_type.rb b/app/graphql/types/ci/config/config_type.rb index 29093c6d3c9..88caf21c376 100644 --- a/app/graphql/types/ci/config/config_type.rb +++ b/app/graphql/types/ci/config/config_type.rb @@ -8,13 +8,13 @@ module Types graphql_name 'CiConfig' field :errors, [GraphQL::STRING_TYPE], null: true, - description: 'Linting errors' + description: 'Linting errors.' field :merged_yaml, GraphQL::STRING_TYPE, null: true, - description: 'Merged CI config YAML' + description: 'Merged CI configuration YAML.' field :stages, Types::Ci::Config::StageType.connection_type, null: true, - description: 'Stages of the pipeline' + description: 'Stages of the pipeline.' field :status, Types::Ci::Config::StatusEnum, null: true, - description: 'Status of linting, can be either valid or invalid' + description: 'Status of linting, can be either valid or invalid.' end end end diff --git a/app/graphql/types/ci/config/group_type.rb b/app/graphql/types/ci/config/group_type.rb index 8e133bbcba8..11be701e73f 100644 --- a/app/graphql/types/ci/config/group_type.rb +++ b/app/graphql/types/ci/config/group_type.rb @@ -8,11 +8,11 @@ module Types graphql_name 'CiConfigGroup' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the job group' + description: 'Name of the job group.' field :jobs, Types::Ci::Config::JobType.connection_type, null: true, - description: 'Jobs in group' + description: 'Jobs in group.' field :size, GraphQL::INT_TYPE, null: true, - description: 'Size of the job group' + description: 'Size of the job group.' end end end diff --git a/app/graphql/types/ci/config/need_type.rb b/app/graphql/types/ci/config/need_type.rb index a442450b9ae..01f73100409 100644 --- a/app/graphql/types/ci/config/need_type.rb +++ b/app/graphql/types/ci/config/need_type.rb @@ -8,7 +8,7 @@ module Types graphql_name 'CiConfigNeed' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the need' + description: 'Name of the need.' end end end diff --git a/app/graphql/types/ci/config/stage_type.rb b/app/graphql/types/ci/config/stage_type.rb index 2008c553629..060efb7d45c 100644 --- a/app/graphql/types/ci/config/stage_type.rb +++ b/app/graphql/types/ci/config/stage_type.rb @@ -8,9 +8,9 @@ module Types graphql_name 'CiConfigStage' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the stage' + description: 'Name of the stage.' field :groups, Types::Ci::Config::GroupType.connection_type, null: true, - description: 'Groups of jobs for the stage' + description: 'Groups of jobs for the stage.' end end end diff --git a/app/graphql/types/ci/detailed_status_type.rb b/app/graphql/types/ci/detailed_status_type.rb index 80d73e9b174..0b643a6b676 100644 --- a/app/graphql/types/ci/detailed_status_type.rb +++ b/app/graphql/types/ci/detailed_status_type.rb @@ -7,26 +7,27 @@ module Types graphql_name 'DetailedStatus' field :group, GraphQL::STRING_TYPE, null: true, - description: 'Group of the status' + description: 'Group of the status.' field :icon, GraphQL::STRING_TYPE, null: true, - description: 'Icon of the status' + description: 'Icon of the status.' field :favicon, GraphQL::STRING_TYPE, null: true, - description: 'Favicon of the status' + description: 'Favicon of the status.' field :details_path, GraphQL::STRING_TYPE, null: true, - description: 'Path of the details for the status' + description: 'Path of the details for the status.' field :has_details, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates if the status has further details', + description: 'Indicates if the status has further details.', method: :has_details? field :label, GraphQL::STRING_TYPE, null: true, - description: 'Label of the status' + calls_gitaly: true, + description: 'Label of the status.' field :text, GraphQL::STRING_TYPE, null: true, - description: 'Text of the status' + description: 'Text of the status.' field :tooltip, GraphQL::STRING_TYPE, null: true, - description: 'Tooltip associated with the status', + description: 'Tooltip associated with the status.', method: :status_tooltip field :action, Types::Ci::StatusActionType, null: true, - calls_gitaly: true, - description: 'Action information for the status. This includes method, button title, icon, path, and title' + calls_gitaly: true, + description: 'Action information for the status. This includes method, button title, icon, path, and title.' def action if object.has_action? diff --git a/app/graphql/types/ci/group_type.rb b/app/graphql/types/ci/group_type.rb index 03fd50d5dbb..d6d4252e8d7 100644 --- a/app/graphql/types/ci/group_type.rb +++ b/app/graphql/types/ci/group_type.rb @@ -7,13 +7,13 @@ module Types graphql_name 'CiGroup' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the job group' + description: 'Name of the job group.' field :size, GraphQL::INT_TYPE, null: true, - description: 'Size of the group' + description: 'Size of the group.' field :jobs, Ci::JobType.connection_type, null: true, - description: 'Jobs in group' + description: 'Jobs in group.' field :detailed_status, Types::Ci::DetailedStatusType, null: true, - description: 'Detailed status of the group' + description: 'Detailed status of the group.' def detailed_status object.detailed_status(context[:current_user]) diff --git a/app/graphql/types/ci/job_artifact_type.rb b/app/graphql/types/ci/job_artifact_type.rb index c34a12dcc61..7dc93041b53 100644 --- a/app/graphql/types/ci/job_artifact_type.rb +++ b/app/graphql/types/ci/job_artifact_type.rb @@ -7,10 +7,10 @@ module Types graphql_name 'CiJobArtifact' field :download_path, GraphQL::STRING_TYPE, null: true, - description: "URL for downloading the artifact's file" + description: "URL for downloading the artifact's file." field :file_type, ::Types::Ci::JobArtifactFileTypeEnum, null: true, - description: 'File type of the artifact' + description: 'File type of the artifact.' def download_path ::Gitlab::Routing.url_helpers.download_project_job_artifacts_path( diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index f8bf1732e63..ba463cdd9c1 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -7,17 +7,17 @@ module Types authorize :read_commit_status field :pipeline, Types::Ci::PipelineType, null: true, - description: 'Pipeline the job belongs to' + description: 'Pipeline the job belongs to.' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the job' + description: 'Name of the job.' field :needs, BuildNeedType.connection_type, null: true, - description: 'References to builds that must complete before the jobs run' + description: 'References to builds that must complete before the jobs run.' field :detailed_status, Types::Ci::DetailedStatusType, null: true, - description: 'Detailed status of the job' + description: 'Detailed status of the job.' field :scheduled_at, Types::TimeType, null: true, - description: 'Schedule for the build' + description: 'Schedule for the build.' field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, - description: 'Artifacts generated by the job' + description: 'Artifacts generated by the job.' def pipeline Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb index 4709d5e8dd6..af7e0fa224f 100644 --- a/app/graphql/types/ci/pipeline_type.rb +++ b/app/graphql/types/ci/pipeline_type.rb @@ -8,94 +8,95 @@ module Types connection_type_class(Types::CountableConnectionType) authorize :read_pipeline + present_using ::Ci::PipelinePresenter expose_permissions Types::PermissionTypes::Ci::Pipeline field :id, GraphQL::ID_TYPE, null: false, - description: 'ID of the pipeline' + description: 'ID of the pipeline.' field :iid, GraphQL::STRING_TYPE, null: false, - description: 'Internal ID of the pipeline' + description: 'Internal ID of the pipeline.' field :sha, GraphQL::STRING_TYPE, null: false, - description: "SHA of the pipeline's commit" + description: "SHA of the pipeline's commit." field :before_sha, GraphQL::STRING_TYPE, null: true, - description: 'Base SHA of the source branch' + description: 'Base SHA of the source branch.' field :status, PipelineStatusEnum, null: false, description: "Status of the pipeline (#{::Ci::Pipeline.all_state_names.compact.join(', ').upcase})" field :detailed_status, Types::Ci::DetailedStatusType, null: false, - description: 'Detailed status of the pipeline' + description: 'Detailed status of the pipeline.' field :config_source, PipelineConfigSourceEnum, null: true, - description: "Config source of the pipeline (#{::Enums::Ci::Pipeline.config_sources.keys.join(', ').upcase})" + description: "Configuration source of the pipeline (#{::Enums::Ci::Pipeline.config_sources.keys.join(', ').upcase})" field :duration, GraphQL::INT_TYPE, null: true, - description: 'Duration of the pipeline in seconds' + description: 'Duration of the pipeline in seconds.' field :coverage, GraphQL::FLOAT_TYPE, null: true, - description: 'Coverage percentage' + description: 'Coverage percentage.' field :created_at, Types::TimeType, null: false, - description: "Timestamp of the pipeline's creation" + description: "Timestamp of the pipeline's creation." field :updated_at, Types::TimeType, null: false, - description: "Timestamp of the pipeline's last activity" + description: "Timestamp of the pipeline's last activity." field :started_at, Types::TimeType, null: true, - description: 'Timestamp when the pipeline was started' + description: 'Timestamp when the pipeline was started.' field :finished_at, Types::TimeType, null: true, - description: "Timestamp of the pipeline's completion" + description: "Timestamp of the pipeline's completion." field :committed_at, Types::TimeType, null: true, - description: "Timestamp of the pipeline's commit" + description: "Timestamp of the pipeline's commit." field :stages, Types::Ci::StageType.connection_type, null: true, - description: 'Stages of the pipeline', + description: 'Stages of the pipeline.', extras: [:lookahead], resolver: Resolvers::Ci::PipelineStagesResolver field :user, Types::UserType, null: true, - description: 'Pipeline user' + description: 'Pipeline user.' field :retryable, GraphQL::BOOLEAN_TYPE, - description: 'Specifies if a pipeline can be retried', + description: 'Specifies if a pipeline can be retried.', method: :retryable?, null: false field :cancelable, GraphQL::BOOLEAN_TYPE, - description: 'Specifies if a pipeline can be canceled', + description: 'Specifies if a pipeline can be canceled.', method: :cancelable?, null: false field :jobs, ::Types::Ci::JobType.connection_type, null: true, - description: 'Jobs belonging to the pipeline', + description: 'Jobs belonging to the pipeline.', resolver: ::Resolvers::Ci::JobsResolver field :source_job, Types::Ci::JobType, null: true, - description: 'Job where pipeline was triggered from' + description: 'Job where pipeline was triggered from.' field :downstream, Types::Ci::PipelineType.connection_type, null: true, - description: 'Pipelines this pipeline will trigger', + description: 'Pipelines this pipeline will trigger.', method: :triggered_pipelines_with_preloads field :upstream, Types::Ci::PipelineType, null: true, - description: 'Pipeline that triggered the pipeline', + description: 'Pipeline that triggered the pipeline.', method: :triggered_by_pipeline field :path, GraphQL::STRING_TYPE, null: true, - description: "Relative path to the pipeline's page" + description: "Relative path to the pipeline's page." field :project, Types::ProjectType, null: true, - description: 'Project the pipeline belongs to' + description: 'Project the pipeline belongs to.' field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?, - description: 'Indicates if the pipeline is active' + description: 'Indicates if the pipeline is active.' def detailed_status object.detailed_status(context[:current_user]) diff --git a/app/graphql/types/ci/runner_architecture_type.rb b/app/graphql/types/ci/runner_architecture_type.rb index 526348abd9d..229974d4d13 100644 --- a/app/graphql/types/ci/runner_architecture_type.rb +++ b/app/graphql/types/ci/runner_architecture_type.rb @@ -7,9 +7,9 @@ module Types graphql_name 'RunnerArchitecture' field :name, GraphQL::STRING_TYPE, null: false, - description: 'Name of the runner platform architecture' + description: 'Name of the runner platform architecture.' field :download_location, GraphQL::STRING_TYPE, null: false, - description: 'Download location for the runner for the platform architecture' + description: 'Download location for the runner for the platform architecture.' end end end diff --git a/app/graphql/types/ci/runner_platform_type.rb b/app/graphql/types/ci/runner_platform_type.rb index 64719bc4908..5636f88835e 100644 --- a/app/graphql/types/ci/runner_platform_type.rb +++ b/app/graphql/types/ci/runner_platform_type.rb @@ -7,11 +7,11 @@ module Types graphql_name 'RunnerPlatform' field :name, GraphQL::STRING_TYPE, null: false, - description: 'Name slug of the runner platform' + description: 'Name slug of the runner platform.' field :human_readable_name, GraphQL::STRING_TYPE, null: false, - description: 'Human readable name of the runner platform' + description: 'Human readable name of the runner platform.' field :architectures, Types::Ci::RunnerArchitectureType.connection_type, null: true, - description: 'Runner architectures supported for the platform' + description: 'Runner architectures supported for the platform.' end end end diff --git a/app/graphql/types/ci/runner_setup_type.rb b/app/graphql/types/ci/runner_setup_type.rb index 66abcf65adf..61a2ea2a411 100644 --- a/app/graphql/types/ci/runner_setup_type.rb +++ b/app/graphql/types/ci/runner_setup_type.rb @@ -7,9 +7,9 @@ module Types graphql_name 'RunnerSetup' field :install_instructions, GraphQL::STRING_TYPE, null: false, - description: 'Instructions for installing the runner on the specified architecture' + description: 'Instructions for installing the runner on the specified architecture.' field :register_instructions, GraphQL::STRING_TYPE, null: true, - description: 'Instructions for registering the runner' + description: 'Instructions for registering the runner.' end end end diff --git a/app/graphql/types/ci/stage_type.rb b/app/graphql/types/ci/stage_type.rb index 695e7c61bd9..836f2430890 100644 --- a/app/graphql/types/ci/stage_type.rb +++ b/app/graphql/types/ci/stage_type.rb @@ -7,12 +7,12 @@ module Types graphql_name 'CiStage' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the stage' + description: 'Name of the stage.' field :groups, Ci::GroupType.connection_type, null: true, extras: [:lookahead], - description: 'Group of jobs for the stage' + description: 'Group of jobs for the stage.' field :detailed_status, Types::Ci::DetailedStatusType, null: true, - description: 'Detailed status of the stage' + description: 'Detailed status of the stage.' def detailed_status object.detailed_status(context[:current_user]) diff --git a/app/graphql/types/ci/status_action_type.rb b/app/graphql/types/ci/status_action_type.rb index 08cbb6d3b59..9f7299c0270 100644 --- a/app/graphql/types/ci/status_action_type.rb +++ b/app/graphql/types/ci/status_action_type.rb @@ -6,16 +6,16 @@ module Types graphql_name 'StatusAction' field :button_title, GraphQL::STRING_TYPE, null: true, - description: 'Title for the button, for example: Retry this job' + description: 'Title for the button, for example: Retry this job.' field :icon, GraphQL::STRING_TYPE, null: true, - description: 'Icon used in the action button' + description: 'Icon used in the action button.' field :method, GraphQL::STRING_TYPE, null: true, - description: 'Method for the action, for example: :post', + description: 'Method for the action, for example: :post.', resolver_method: :action_method field :path, GraphQL::STRING_TYPE, null: true, - description: 'Path for the action' + description: 'Path for the action.' field :title, GraphQL::STRING_TYPE, null: true, - description: 'Title for the action, for example: Retry' + description: 'Title for the action, for example: Retry.' def action_method object[:method] diff --git a/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb b/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb new file mode 100644 index 00000000000..9835a7ef208 --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + # rubocop: disable Graphql/AuthorizeTypes + class AnalyzersEntityInputType < BaseInputObject + graphql_name 'SastCiConfigurationAnalyzersEntityInput' + description 'Represents the analyzers entity in SAST CI configuration' + + argument :name, GraphQL::STRING_TYPE, required: true, + description: 'Name of analyzer.' + + argument :enabled, GraphQL::BOOLEAN_TYPE, required: true, + description: 'State of the analyzer.' + + argument :variables, [::Types::CiConfiguration::Sast::EntityInputType], + description: 'List of variables for the analyzer.', + required: false + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb new file mode 100644 index 00000000000..3c6202ca7e0 --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + # rubocop: disable Graphql/AuthorizeTypes + class AnalyzersEntityType < BaseObject + graphql_name 'SastCiConfigurationAnalyzersEntity' + description 'Represents an analyzer entity in SAST CI configuration' + + field :name, GraphQL::STRING_TYPE, null: true, + description: 'Name of the analyzer.' + + field :label, GraphQL::STRING_TYPE, null: true, + description: 'Analyzer label used in the config UI.' + + field :enabled, GraphQL::BOOLEAN_TYPE, null: true, + description: 'Indicates whether an analyzer is enabled.' + + field :description, GraphQL::STRING_TYPE, null: true, + description: 'Analyzer description that is displayed on the form.' + + field :variables, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true, + description: 'List of supported variables.' + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/entity_input_type.rb b/app/graphql/types/ci_configuration/sast/entity_input_type.rb new file mode 100644 index 00000000000..39b3efb3db8 --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/entity_input_type.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + # rubocop: disable Graphql/AuthorizeTypes + class EntityInputType < BaseInputObject + graphql_name 'SastCiConfigurationEntityInput' + description 'Represents an entity in SAST CI configuration' + + argument :field, GraphQL::STRING_TYPE, required: true, + description: 'CI keyword of entity.' + + argument :default_value, GraphQL::STRING_TYPE, required: true, + description: 'Default value that is used if value is empty.' + + argument :value, GraphQL::STRING_TYPE, required: true, + description: 'Current value of the entity.' + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/entity_type.rb b/app/graphql/types/ci_configuration/sast/entity_type.rb new file mode 100644 index 00000000000..eeb9025391f --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/entity_type.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + # rubocop: disable Graphql/AuthorizeTypes + class EntityType < BaseObject + graphql_name 'SastCiConfigurationEntity' + description 'Represents an entity in SAST CI configuration' + + field :field, GraphQL::STRING_TYPE, null: true, + description: 'CI keyword of entity.' + + field :label, GraphQL::STRING_TYPE, null: true, + description: 'Label for entity used in the form.' + + field :type, GraphQL::STRING_TYPE, null: true, + description: 'Type of the field value.' + + field :options, ::Types::CiConfiguration::Sast::OptionsEntityType.connection_type, null: true, + description: 'Different possible values of the field.' + + field :default_value, GraphQL::STRING_TYPE, null: true, + description: 'Default value that is used if value is empty.' + + field :description, GraphQL::STRING_TYPE, null: true, + description: 'Entity description that is displayed on the form.' + + field :value, GraphQL::STRING_TYPE, null: true, + description: 'Current value of the entity.' + + field :size, ::Types::CiConfiguration::Sast::UiComponentSizeEnum, null: true, + description: 'Size of the UI component.' + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/input_type.rb b/app/graphql/types/ci_configuration/sast/input_type.rb new file mode 100644 index 00000000000..615436683f6 --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/input_type.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + class InputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes + graphql_name 'SastCiConfigurationInput' + description 'Represents a CI configuration of SAST' + + argument :global, [::Types::CiConfiguration::Sast::EntityInputType], + description: 'List of global entities related to SAST configuration.', + required: false + + argument :pipeline, [::Types::CiConfiguration::Sast::EntityInputType], + description: 'List of pipeline entities related to SAST configuration.', + required: false + + argument :analyzers, [::Types::CiConfiguration::Sast::AnalyzersEntityInputType], + description: 'List of analyzers and related variables for the SAST configuration.', + required: false + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/options_entity_type.rb b/app/graphql/types/ci_configuration/sast/options_entity_type.rb new file mode 100644 index 00000000000..86d104a7fda --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/options_entity_type.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + # rubocop: disable Graphql/AuthorizeTypes + class OptionsEntityType < BaseObject + graphql_name 'SastCiConfigurationOptionsEntity' + description 'Represents an entity for options in SAST CI configuration' + + field :label, GraphQL::STRING_TYPE, null: true, + description: 'Label of option entity.' + + field :value, GraphQL::STRING_TYPE, null: true, + description: 'Value of option entity.' + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/type.rb b/app/graphql/types/ci_configuration/sast/type.rb new file mode 100644 index 00000000000..35d11584ac7 --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/type.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + # rubocop: disable Graphql/AuthorizeTypes + class Type < BaseObject + graphql_name 'SastCiConfiguration' + description 'Represents a CI configuration of SAST' + + field :global, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true, + description: 'List of global entities related to SAST configuration.' + + field :pipeline, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true, + description: 'List of pipeline entities related to SAST configuration.' + + field :analyzers, ::Types::CiConfiguration::Sast::AnalyzersEntityType.connection_type, null: true, + description: 'List of analyzers entities attached to SAST configuration.' + end + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/ui_component_size_enum.rb b/app/graphql/types/ci_configuration/sast/ui_component_size_enum.rb new file mode 100644 index 00000000000..3a208f9d3e4 --- /dev/null +++ b/app/graphql/types/ci_configuration/sast/ui_component_size_enum.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Types + module CiConfiguration + module Sast + class UiComponentSizeEnum < BaseEnum + graphql_name 'SastUiComponentSize' + description 'Size of UI component in SAST configuration page' + + value 'SMALL' + value 'MEDIUM' + value 'LARGE' + end + end + end +end diff --git a/app/graphql/types/commit_action_type.rb b/app/graphql/types/commit_action_type.rb index 7674abb11eb..e14e7157752 100644 --- a/app/graphql/types/commit_action_type.rb +++ b/app/graphql/types/commit_action_type.rb @@ -4,19 +4,19 @@ module Types # rubocop: disable Graphql/AuthorizeTypes class CommitActionType < BaseInputObject argument :action, type: Types::CommitActionModeEnum, required: true, - description: 'The action to perform, create, delete, move, update, chmod' + description: 'The action to perform, create, delete, move, update, chmod.' argument :file_path, type: GraphQL::STRING_TYPE, required: true, - description: 'Full path to the file' + description: 'Full path to the file.' argument :content, type: GraphQL::STRING_TYPE, required: false, - description: 'Content of the file' + description: 'Content of the file.' argument :previous_path, type: GraphQL::STRING_TYPE, required: false, - description: 'Original full path to the file being moved' + description: 'Original full path to the file being moved.' argument :last_commit_id, type: GraphQL::STRING_TYPE, required: false, - description: 'Last known file commit ID' + description: 'Last known file commit ID.' argument :execute_filemode, type: GraphQL::BOOLEAN_TYPE, required: false, - description: 'Enables/disables the execute flag on the file' + description: 'Enables/disables the execute flag on the file.' argument :encoding, type: Types::CommitEncodingEnum, required: false, - description: 'Encoding of the file. Default is text' + description: 'Encoding of the file. Default is text.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb index 37d19b4148b..d137901380b 100644 --- a/app/graphql/types/commit_type.rb +++ b/app/graphql/types/commit_type.rb @@ -9,39 +9,39 @@ module Types present_using CommitPresenter field :id, type: GraphQL::ID_TYPE, null: false, - description: 'ID (global ID) of the commit' + description: 'ID (global ID) of the commit.' field :sha, type: GraphQL::STRING_TYPE, null: false, - description: 'SHA1 ID of the commit' + description: 'SHA1 ID of the commit.' field :short_id, type: GraphQL::STRING_TYPE, null: false, - description: 'Short SHA1 ID of the commit' + description: 'Short SHA1 ID of the commit.' field :title, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, - description: 'Title of the commit message' + description: 'Title of the commit message.' markdown_field :title_html, null: true field :description, type: GraphQL::STRING_TYPE, null: true, - description: 'Description of the commit message' + description: 'Description of the commit message.' markdown_field :description_html, null: true field :message, type: GraphQL::STRING_TYPE, null: true, - description: 'Raw commit message' + description: 'Raw commit message.' field :authored_date, type: Types::TimeType, null: true, - description: 'Timestamp of when the commit was authored' + description: 'Timestamp of when the commit was authored.' field :web_url, type: GraphQL::STRING_TYPE, null: false, - description: 'Web URL of the commit' + description: 'Web URL of the commit.' field :web_path, type: GraphQL::STRING_TYPE, null: false, - description: 'Web path of the commit' + description: 'Web path of the commit.' field :signature_html, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, - description: 'Rendered HTML of the commit signature' + description: 'Rendered HTML of the commit signature.' field :author_name, type: GraphQL::STRING_TYPE, null: true, - description: 'Commit authors name' + description: 'Commit authors name.' field :author_gravatar, type: GraphQL::STRING_TYPE, null: true, - description: 'Commit authors gravatar' + description: 'Commit authors gravatar.' # models/commit lazy loads the author by email field :author, type: Types::UserType, null: true, - description: 'Author of the commit' + description: 'Author of the commit.' field :pipelines, null: true, - description: 'Pipelines of the commit ordered latest first', + description: 'Pipelines of the commit ordered latest first.', resolver: Resolvers::CommitPipelinesResolver def author_gravatar diff --git a/app/graphql/types/container_expiration_policy_type.rb b/app/graphql/types/container_expiration_policy_type.rb index f19aa964377..2b01474617a 100644 --- a/app/graphql/types/container_expiration_policy_type.rb +++ b/app/graphql/types/container_expiration_policy_type.rb @@ -8,14 +8,14 @@ module Types authorize :destroy_container_image - field :created_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was created' - field :updated_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was updated' - field :enabled, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates whether this container expiration policy is enabled' - field :older_than, Types::ContainerExpirationPolicyOlderThanEnum, null: true, description: 'Tags older that this will expire' - field :cadence, Types::ContainerExpirationPolicyCadenceEnum, null: false, description: 'This container expiration policy schedule' - field :keep_n, Types::ContainerExpirationPolicyKeepEnum, null: true, description: 'Number of tags to retain' - field :name_regex, Types::UntrustedRegexp, null: true, description: 'Tags with names matching this regex pattern will expire' - field :name_regex_keep, Types::UntrustedRegexp, null: true, description: 'Tags with names matching this regex pattern will be preserved' - field :next_run_at, Types::TimeType, null: true, description: 'Next time that this container expiration policy will get executed' + field :created_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was created.' + field :updated_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was updated.' + field :enabled, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates whether this container expiration policy is enabled.' + field :older_than, Types::ContainerExpirationPolicyOlderThanEnum, null: true, description: 'Tags older that this will expire.' + field :cadence, Types::ContainerExpirationPolicyCadenceEnum, null: false, description: 'This container expiration policy schedule.' + field :keep_n, Types::ContainerExpirationPolicyKeepEnum, null: true, description: 'Number of tags to retain.' + field :name_regex, Types::UntrustedRegexp, null: true, description: 'Tags with names matching this regex pattern will expire.' + field :name_regex_keep, Types::UntrustedRegexp, null: true, description: 'Tags with names matching this regex pattern will be preserved.' + field :next_run_at, Types::TimeType, null: true, description: 'Next time that this container expiration policy will get executed.' end end diff --git a/app/graphql/types/container_repository_details_type.rb b/app/graphql/types/container_repository_details_type.rb index 34523f3ea4a..1a9f57e701f 100644 --- a/app/graphql/types/container_repository_details_type.rb +++ b/app/graphql/types/container_repository_details_type.rb @@ -11,7 +11,7 @@ module Types field :tags, Types::ContainerRepositoryTagType.connection_type, null: true, - description: 'Tags of the container repository', + description: 'Tags of the container repository.', max_page_size: 20 def can_delete diff --git a/app/graphql/types/container_repository_type.rb b/app/graphql/types/container_repository_type.rb index 8735f8a173d..48c2b9f460f 100644 --- a/app/graphql/types/container_repository_type.rb +++ b/app/graphql/types/container_repository_type.rb @@ -19,7 +19,7 @@ module Types field :status, Types::ContainerRepositoryStatusEnum, null: true, description: 'Status of the container repository.' field :tags_count, GraphQL::INT_TYPE, null: false, description: 'Number of tags associated with this image.' field :can_delete, GraphQL::BOOLEAN_TYPE, null: false, description: 'Can the current user delete the container repository.' - field :project, Types::ProjectType, null: false, description: 'Project of the container registry' + field :project, Types::ProjectType, null: false, description: 'Project of the container registry.' def can_delete Ability.allowed?(current_user, :update_container_image, object) diff --git a/app/graphql/types/countable_connection_type.rb b/app/graphql/types/countable_connection_type.rb index f67194d99b3..0a9699a4570 100644 --- a/app/graphql/types/countable_connection_type.rb +++ b/app/graphql/types/countable_connection_type.rb @@ -4,7 +4,7 @@ module Types # rubocop: disable Graphql/AuthorizeTypes class CountableConnectionType < GraphQL::Types::Relay::BaseConnection field :count, GraphQL::INT_TYPE, null: false, - description: 'Total count of collection' + description: 'Total count of collection.' def count # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/graphql/types/current_user_todos.rb b/app/graphql/types/current_user_todos.rb index e610286c1a9..79a430af1d7 100644 --- a/app/graphql/types/current_user_todos.rb +++ b/app/graphql/types/current_user_todos.rb @@ -8,10 +8,10 @@ module Types field_class Types::BaseField field :current_user_todos, Types::TodoType.connection_type, - description: 'Todos for the current user', + description: 'To-do items for the current user.', null: false do argument :state, Types::TodoStateEnum, - description: 'State of the todos', + description: 'State of the to-do items.', required: false end diff --git a/app/graphql/types/custom_emoji_type.rb b/app/graphql/types/custom_emoji_type.rb index f7d1a7800bc..246b60ce184 100644 --- a/app/graphql/types/custom_emoji_type.rb +++ b/app/graphql/types/custom_emoji_type.rb @@ -9,19 +9,19 @@ module Types field :id, ::Types::GlobalIDType[::CustomEmoji], null: false, - description: 'The ID of the emoji' + description: 'The ID of the emoji.' field :name, GraphQL::STRING_TYPE, null: false, - description: 'The name of the emoji' + description: 'The name of the emoji.' field :url, GraphQL::STRING_TYPE, null: false, method: :file, - description: 'The link to file of the emoji' + description: 'The link to file of the emoji.' field :external, GraphQL::BOOLEAN_TYPE, null: false, - description: 'Whether the emoji is an external link' + description: 'Whether the emoji is an external link.' end end diff --git a/app/graphql/types/design_management/design_at_version_type.rb b/app/graphql/types/design_management/design_at_version_type.rb index e10a0de1715..4240b8f3aae 100644 --- a/app/graphql/types/design_management/design_at_version_type.rb +++ b/app/graphql/types/design_management/design_at_version_type.rb @@ -18,12 +18,12 @@ module Types field :version, Types::DesignManagement::VersionType, null: false, - description: 'The version this design-at-versions is pinned to' + description: 'The version this design-at-versions is pinned to.' field :design, Types::DesignManagement::DesignType, null: false, - description: 'The underlying design' + description: 'The underlying design.' def cached_stateful_version(_parent) version diff --git a/app/graphql/types/design_management/design_collection_type.rb b/app/graphql/types/design_management/design_collection_type.rb index 26fbac15b30..570eac907f3 100644 --- a/app/graphql/types/design_management/design_collection_type.rb +++ b/app/graphql/types/design_management/design_collection_type.rb @@ -9,40 +9,40 @@ module Types authorize :read_design field :project, Types::ProjectType, null: false, - description: 'Project associated with the design collection' + description: 'Project associated with the design collection.' field :issue, Types::IssueType, null: false, - description: 'Issue associated with the design collection' + description: 'Issue associated with the design collection.' field :designs, Types::DesignManagement::DesignType.connection_type, null: false, resolver: Resolvers::DesignManagement::DesignsResolver, - description: 'All designs for the design collection', + description: 'All designs for the design collection.', complexity: 5 field :versions, Types::DesignManagement::VersionType.connection_type, resolver: Resolvers::DesignManagement::VersionsResolver, - description: 'All versions related to all designs, ordered newest first' + description: 'All versions related to all designs, ordered newest first.' field :version, Types::DesignManagement::VersionType, resolver: Resolvers::DesignManagement::VersionsResolver.single, - description: 'A specific version' + description: 'A specific version.' field :design_at_version, ::Types::DesignManagement::DesignAtVersionType, null: true, resolver: ::Resolvers::DesignManagement::DesignAtVersionResolver, - description: 'Find a design as of a version' + description: 'Find a design as of a version.' field :design, ::Types::DesignManagement::DesignType, null: true, resolver: ::Resolvers::DesignManagement::DesignResolver, - description: 'Find a specific design' + description: 'Find a specific design.' field :copy_state, ::Types::DesignManagement::DesignCollectionCopyStateEnum, null: true, - description: 'Copy state of the design collection' + description: 'Copy state of the design collection.' end end end diff --git a/app/graphql/types/design_management/design_fields.rb b/app/graphql/types/design_management/design_fields.rb index b03b3927392..b770e30f5be 100644 --- a/app/graphql/types/design_management/design_fields.rb +++ b/app/graphql/types/design_management/design_fields.rb @@ -7,12 +7,12 @@ module Types field_class Types::BaseField - field :id, GraphQL::ID_TYPE, description: 'The ID of this design', null: false - field :project, Types::ProjectType, null: false, description: 'The project the design belongs to' - field :issue, Types::IssueType, null: false, description: 'The issue the design belongs to' - field :filename, GraphQL::STRING_TYPE, null: false, description: 'The filename of the design' - field :full_path, GraphQL::STRING_TYPE, null: false, description: 'The full path to the design file' - field :image, GraphQL::STRING_TYPE, null: false, extras: [:parent], description: 'The URL of the full-sized image' + field :id, GraphQL::ID_TYPE, description: 'The ID of this design.', null: false + field :project, Types::ProjectType, null: false, description: 'The project the design belongs to.' + field :issue, Types::IssueType, null: false, description: 'The issue the design belongs to.' + field :filename, GraphQL::STRING_TYPE, null: false, description: 'The filename of the design.' + field :full_path, GraphQL::STRING_TYPE, null: false, description: 'The full path to the design file.' + field :image, GraphQL::STRING_TYPE, null: false, extras: [:parent], description: 'The URL of the full-sized image.' field :image_v432x230, GraphQL::STRING_TYPE, null: true, extras: [:parent], description: 'The URL of the design resized to fit within the bounds of 432x230. ' \ 'This will be `null` if the image has not been generated' @@ -20,16 +20,16 @@ module Types null: false, calls_gitaly: true, extras: [:parent], - description: 'The diff refs for this design' + description: 'The diff refs for this design.' field :event, Types::DesignManagement::DesignVersionEventEnum, null: false, extras: [:parent], - description: 'How this design was changed in the current version' + description: 'How this design was changed in the current version.' field :notes_count, GraphQL::INT_TYPE, null: false, method: :user_notes_count, - description: 'The total count of user-created notes for this design' + description: 'The total count of user-created notes for this design.' def diff_refs(parent:) version = cached_stateful_version(parent) diff --git a/app/graphql/types/design_management/design_type.rb b/app/graphql/types/design_management/design_type.rb index bab22015dc4..44e87905f92 100644 --- a/app/graphql/types/design_management/design_type.rb +++ b/app/graphql/types/design_management/design_type.rb @@ -17,7 +17,7 @@ module Types field :versions, Types::DesignManagement::VersionType.connection_type, resolver: Resolvers::DesignManagement::VersionsResolver, - description: "All versions related to this design ordered newest first", + description: "All versions related to this design ordered newest first.", extras: [:parent] # Returns a `DesignManagement::Version` for this query based on the diff --git a/app/graphql/types/design_management/version_type.rb b/app/graphql/types/design_management/version_type.rb index c774f5d1bdf..4bc71aef0f4 100644 --- a/app/graphql/types/design_management/version_type.rb +++ b/app/graphql/types/design_management/version_type.rb @@ -12,25 +12,25 @@ module Types authorize :read_design field :id, GraphQL::ID_TYPE, null: false, - description: 'ID of the design version' + description: 'ID of the design version.' field :sha, GraphQL::ID_TYPE, null: false, - description: 'SHA of the design version' + description: 'SHA of the design version.' field :designs, ::Types::DesignManagement::DesignType.connection_type, null: false, - description: 'All designs that were changed in the version' + description: 'All designs that were changed in the version.' field :designs_at_version, ::Types::DesignManagement::DesignAtVersionType.connection_type, null: false, - description: 'All designs that are visible at this version, as of this version', + description: 'All designs that are visible at this version, as of this version.', resolver: ::Resolvers::DesignManagement::Version::DesignsAtVersionResolver field :design_at_version, ::Types::DesignManagement::DesignAtVersionType, null: false, - description: 'A particular design as of this version, provided it is visible at this version', + description: 'A particular design as of this version, provided it is visible at this version.', resolver: ::Resolvers::DesignManagement::Version::DesignsAtVersionResolver.single end end diff --git a/app/graphql/types/design_management_type.rb b/app/graphql/types/design_management_type.rb index ec85b8a0c1f..be0fb8253ca 100644 --- a/app/graphql/types/design_management_type.rb +++ b/app/graphql/types/design_management_type.rb @@ -8,11 +8,11 @@ module Types field :version, ::Types::DesignManagement::VersionType, null: true, resolver: ::Resolvers::DesignManagement::VersionResolver, - description: 'Find a version' + description: 'Find a version.' field :design_at_version, ::Types::DesignManagement::DesignAtVersionType, null: true, resolver: ::Resolvers::DesignManagement::DesignAtVersionResolver, - description: 'Find a design as of a version' + description: 'Find a design as of a version.' end end diff --git a/app/graphql/types/diff_paths_input_type.rb b/app/graphql/types/diff_paths_input_type.rb index 43feddd9827..864cec1ab07 100644 --- a/app/graphql/types/diff_paths_input_type.rb +++ b/app/graphql/types/diff_paths_input_type.rb @@ -4,9 +4,9 @@ module Types # rubocop: disable Graphql/AuthorizeTypes class DiffPathsInputType < BaseInputObject argument :old_path, GraphQL::STRING_TYPE, required: false, - description: 'The path of the file on the start sha' + description: 'The path of the file on the start sha.' argument :new_path, GraphQL::STRING_TYPE, required: false, - description: 'The path of the file on the head sha' + description: 'The path of the file on the head sha.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/diff_refs_type.rb b/app/graphql/types/diff_refs_type.rb index 4049a204f66..3c8f934f1eb 100644 --- a/app/graphql/types/diff_refs_type.rb +++ b/app/graphql/types/diff_refs_type.rb @@ -7,11 +7,11 @@ module Types graphql_name 'DiffRefs' field :head_sha, GraphQL::STRING_TYPE, null: false, - description: 'SHA of the HEAD at the time the comment was made' + description: 'SHA of the HEAD at the time the comment was made.' field :base_sha, GraphQL::STRING_TYPE, null: true, - description: 'Merge base of the branch the comment was made on' + description: 'Merge base of the branch the comment was made on.' field :start_sha, GraphQL::STRING_TYPE, null: false, - description: 'SHA of the branch being compared against' + description: 'SHA of the branch being compared against.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/diff_stats_summary_type.rb b/app/graphql/types/diff_stats_summary_type.rb index 956400fd21b..78c0e2f2b4c 100644 --- a/app/graphql/types/diff_stats_summary_type.rb +++ b/app/graphql/types/diff_stats_summary_type.rb @@ -9,13 +9,13 @@ module Types description 'Aggregated summary of changes' field :additions, GraphQL::INT_TYPE, null: false, - description: 'Number of lines added' + description: 'Number of lines added.' field :deletions, GraphQL::INT_TYPE, null: false, - description: 'Number of lines deleted' + description: 'Number of lines deleted.' field :changes, GraphQL::INT_TYPE, null: false, - description: 'Number of lines changed' + description: 'Number of lines changed.' field :file_count, GraphQL::INT_TYPE, null: false, - description: 'Number of files changed' + description: 'Number of files changed.' def changes object[:additions] + object[:deletions] diff --git a/app/graphql/types/diff_stats_type.rb b/app/graphql/types/diff_stats_type.rb index 6c79a4c389d..8a6840e5a94 100644 --- a/app/graphql/types/diff_stats_type.rb +++ b/app/graphql/types/diff_stats_type.rb @@ -9,11 +9,11 @@ module Types description 'Changes to a single file' field :path, GraphQL::STRING_TYPE, null: false, - description: 'File path, relative to repository root' + description: 'File path, relative to repository root.' field :additions, GraphQL::INT_TYPE, null: false, - description: 'Number of lines added to this file' + description: 'Number of lines added to this file.' field :deletions, GraphQL::INT_TYPE, null: false, - description: 'Number of lines deleted from this file' + description: 'Number of lines deleted from this file.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index e3885668643..2e6417f08ea 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -10,24 +10,24 @@ module Types authorize :read_environment field :name, GraphQL::STRING_TYPE, null: false, - description: 'Human-readable name of the environment' + description: 'Human-readable name of the environment.' field :id, GraphQL::ID_TYPE, null: false, - description: 'ID of the environment' + description: 'ID of the environment.' field :state, GraphQL::STRING_TYPE, null: false, - description: 'State of the environment, for example: available/stopped' + description: 'State of the environment, for example: available/stopped.' field :path, GraphQL::STRING_TYPE, null: false, description: 'The path to the environment.' field :metrics_dashboard, Types::Metrics::DashboardType, null: true, - description: 'Metrics dashboard schema for the environment', + description: 'Metrics dashboard schema for the environment.', resolver: Resolvers::Metrics::DashboardResolver field :latest_opened_most_severe_alert, Types::AlertManagement::AlertType, null: true, - description: 'The most severe open alert for the environment. If multiple alerts have equal severity, the most recent is returned' + description: 'The most severe open alert for the environment. If multiple alerts have equal severity, the most recent is returned.' end end diff --git a/app/graphql/types/error_tracking/sentry_detailed_error_type.rb b/app/graphql/types/error_tracking/sentry_detailed_error_type.rb index cfde9fa0d6a..59bd97e3448 100644 --- a/app/graphql/types/error_tracking/sentry_detailed_error_type.rb +++ b/app/graphql/types/error_tracking/sentry_detailed_error_type.rb @@ -12,93 +12,93 @@ module Types field :id, GraphQL::ID_TYPE, null: false, - description: 'ID (global ID) of the error' + description: 'ID (global ID) of the error.' field :sentry_id, GraphQL::STRING_TYPE, method: :id, null: false, - description: 'ID (Sentry ID) of the error' + description: 'ID (Sentry ID) of the error.' field :title, GraphQL::STRING_TYPE, null: false, - description: 'Title of the error' + description: 'Title of the error.' field :type, GraphQL::STRING_TYPE, null: false, - description: 'Type of the error' + description: 'Type of the error.' field :user_count, GraphQL::INT_TYPE, null: false, - description: 'Count of users affected by the error' + description: 'Count of users affected by the error.' field :count, GraphQL::INT_TYPE, null: false, - description: 'Count of occurrences' + description: 'Count of occurrences.' field :first_seen, Types::TimeType, null: false, - description: 'Timestamp when the error was first seen' + description: 'Timestamp when the error was first seen.' field :last_seen, Types::TimeType, null: false, - description: 'Timestamp when the error was last seen' + description: 'Timestamp when the error was last seen.' field :message, GraphQL::STRING_TYPE, null: true, - description: 'Sentry metadata message of the error' + description: 'Sentry metadata message of the error.' field :culprit, GraphQL::STRING_TYPE, null: false, - description: 'Culprit of the error' + description: 'Culprit of the error.' field :external_base_url, GraphQL::STRING_TYPE, null: false, - description: 'External Base URL of the Sentry Instance' + description: 'External Base URL of the Sentry Instance.' field :external_url, GraphQL::STRING_TYPE, null: false, - description: 'External URL of the error' + description: 'External URL of the error.' field :sentry_project_id, GraphQL::ID_TYPE, method: :project_id, null: false, - description: 'ID of the project (Sentry project)' + description: 'ID of the project (Sentry project).' field :sentry_project_name, GraphQL::STRING_TYPE, method: :project_name, null: false, - description: 'Name of the project affected by the error' + description: 'Name of the project affected by the error.' field :sentry_project_slug, GraphQL::STRING_TYPE, method: :project_slug, null: false, - description: 'Slug of the project affected by the error' + description: 'Slug of the project affected by the error.' field :short_id, GraphQL::STRING_TYPE, null: false, - description: 'Short ID (Sentry ID) of the error' + description: 'Short ID (Sentry ID) of the error.' field :status, Types::ErrorTracking::SentryErrorStatusEnum, null: false, - description: 'Status of the error' + description: 'Status of the error.' field :frequency, [Types::ErrorTracking::SentryErrorFrequencyType], null: false, - description: 'Last 24hr stats of the error' + description: 'Last 24hr stats of the error.' field :first_release_last_commit, GraphQL::STRING_TYPE, null: true, - description: 'Commit the error was first seen' + description: 'Commit the error was first seen.' field :last_release_last_commit, GraphQL::STRING_TYPE, null: true, - description: 'Commit the error was last seen' + description: 'Commit the error was last seen.' field :first_release_short_version, GraphQL::STRING_TYPE, null: true, - description: 'Release short version the error was first seen' + description: 'Release short version the error was first seen.' field :last_release_short_version, GraphQL::STRING_TYPE, null: true, - description: 'Release short version the error was last seen' + description: 'Release short version the error was last seen.' field :first_release_version, GraphQL::STRING_TYPE, null: true, - description: 'Release version the error was first seen' + description: 'Release version the error was first seen.' field :last_release_version, GraphQL::STRING_TYPE, null: true, - description: 'Release version the error was last seen' + description: 'Release version the error was last seen.' field :gitlab_commit, GraphQL::STRING_TYPE, null: true, - description: 'GitLab commit SHA attributed to the Error based on the release version' + description: 'GitLab commit SHA attributed to the Error based on the release version.' field :gitlab_commit_path, GraphQL::STRING_TYPE, null: true, - description: 'Path to the GitLab page for the GitLab commit attributed to the error' + description: 'Path to the GitLab page for the GitLab commit attributed to the error.' field :gitlab_issue_path, GraphQL::STRING_TYPE, method: :gitlab_issue, null: true, - description: 'URL of GitLab Issue' + description: 'URL of GitLab Issue.' field :tags, Types::ErrorTracking::SentryErrorTagsType, null: false, - description: 'Tags associated with the Sentry Error' + description: 'Tags associated with the Sentry Error.' end end end diff --git a/app/graphql/types/error_tracking/sentry_error_collection_type.rb b/app/graphql/types/error_tracking/sentry_error_collection_type.rb index 49d5d62c860..d3941b7c410 100644 --- a/app/graphql/types/error_tracking/sentry_error_collection_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_collection_type.rb @@ -9,18 +9,18 @@ module Types authorize :read_sentry_issue field :errors, - description: "Collection of Sentry Errors", + description: "Collection of Sentry Errors.", resolver: Resolvers::ErrorTracking::SentryErrorsResolver field :detailed_error, - description: 'Detailed version of a Sentry error on the project', + description: 'Detailed version of a Sentry error on the project.', resolver: Resolvers::ErrorTracking::SentryDetailedErrorResolver field :error_stack_trace, - description: 'Stack Trace of Sentry Error', + description: 'Stack Trace of Sentry Error.', resolver: Resolvers::ErrorTracking::SentryErrorStackTraceResolver field :external_url, GraphQL::STRING_TYPE, null: true, - description: "External URL for Sentry" + description: "External URL for Sentry." end end end diff --git a/app/graphql/types/error_tracking/sentry_error_frequency_type.rb b/app/graphql/types/error_tracking/sentry_error_frequency_type.rb index a44ca0684b6..05af1391af3 100644 --- a/app/graphql/types/error_tracking/sentry_error_frequency_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_frequency_type.rb @@ -8,10 +8,10 @@ module Types field :time, Types::TimeType, null: false, - description: "Time the error frequency stats were recorded" + description: "Time the error frequency stats were recorded." field :count, GraphQL::INT_TYPE, null: false, - description: "Count of errors received since the previously recorded time" + description: "Count of errors received since the previously recorded time." end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb index e6d02c948d5..0b3c4cf55b9 100644 --- a/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb @@ -10,11 +10,11 @@ module Types field :line, GraphQL::INT_TYPE, null: false, - description: 'Line number of the context' + description: 'Line number of the context.' field :code, GraphQL::STRING_TYPE, null: false, - description: 'Code number of the context' + description: 'Code number of the context.' def line object[0] diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb index 2e6c40b233b..c9915d052f9 100644 --- a/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb @@ -9,19 +9,19 @@ module Types field :function, GraphQL::STRING_TYPE, null: true, - description: 'Function in which the Sentry error occurred' + description: 'Function in which the Sentry error occurred.' field :col, GraphQL::STRING_TYPE, null: true, - description: 'Function in which the Sentry error occurred' + description: 'Function in which the Sentry error occurred.' field :line, GraphQL::STRING_TYPE, null: true, - description: 'Function in which the Sentry error occurred' + description: 'Function in which the Sentry error occurred.' field :file_name, GraphQL::STRING_TYPE, null: true, - description: 'File in which the Sentry error occurred' + description: 'File in which the Sentry error occurred.' field :trace_context, [Types::ErrorTracking::SentryErrorStackTraceContextType], null: true, - description: 'Context of the Sentry error' + description: 'Context of the Sentry error.' def function object['function'] diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb index 1bbe7e0c77b..52959a9329b 100644 --- a/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb @@ -10,13 +10,13 @@ module Types field :issue_id, GraphQL::STRING_TYPE, null: false, - description: 'ID of the Sentry error' + description: 'ID of the Sentry error.' field :date_received, GraphQL::STRING_TYPE, null: false, - description: 'Time the stack trace was received by Sentry' + description: 'Time the stack trace was received by Sentry.' field :stack_trace_entries, [Types::ErrorTracking::SentryErrorStackTraceEntryType], null: false, - description: 'Stack trace entries for the Sentry error' + description: 'Stack trace entries for the Sentry error.' end end end diff --git a/app/graphql/types/error_tracking/sentry_error_tags_type.rb b/app/graphql/types/error_tracking/sentry_error_tags_type.rb index e6d96571561..e2b051998c5 100644 --- a/app/graphql/types/error_tracking/sentry_error_tags_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_tags_type.rb @@ -9,10 +9,10 @@ module Types field :level, GraphQL::STRING_TYPE, null: true, - description: "Severity level of the Sentry Error" + description: "Severity level of the Sentry Error." field :logger, GraphQL::STRING_TYPE, null: true, - description: "Logger of the Sentry Error" + description: "Logger of the Sentry Error." end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/error_tracking/sentry_error_type.rb b/app/graphql/types/error_tracking/sentry_error_type.rb index 693ab0c4f8f..c0e09fb8c65 100644 --- a/app/graphql/types/error_tracking/sentry_error_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_type.rb @@ -11,59 +11,59 @@ module Types field :id, GraphQL::ID_TYPE, null: false, - description: 'ID (global ID) of the error' + description: 'ID (global ID) of the error.' field :sentry_id, GraphQL::STRING_TYPE, method: :id, null: false, - description: 'ID (Sentry ID) of the error' + description: 'ID (Sentry ID) of the error.' field :first_seen, Types::TimeType, null: false, - description: 'Timestamp when the error was first seen' + description: 'Timestamp when the error was first seen.' field :last_seen, Types::TimeType, null: false, - description: 'Timestamp when the error was last seen' + description: 'Timestamp when the error was last seen.' field :title, GraphQL::STRING_TYPE, null: false, - description: 'Title of the error' + description: 'Title of the error.' field :type, GraphQL::STRING_TYPE, null: false, - description: 'Type of the error' + description: 'Type of the error.' field :user_count, GraphQL::INT_TYPE, null: false, - description: 'Count of users affected by the error' + description: 'Count of users affected by the error.' field :count, GraphQL::INT_TYPE, null: false, - description: 'Count of occurrences' + description: 'Count of occurrences.' field :message, GraphQL::STRING_TYPE, null: true, - description: 'Sentry metadata message of the error' + description: 'Sentry metadata message of the error.' field :culprit, GraphQL::STRING_TYPE, null: false, - description: 'Culprit of the error' + description: 'Culprit of the error.' field :external_url, GraphQL::STRING_TYPE, null: false, - description: 'External URL of the error' + description: 'External URL of the error.' field :short_id, GraphQL::STRING_TYPE, null: false, - description: 'Short ID (Sentry ID) of the error' + description: 'Short ID (Sentry ID) of the error.' field :status, Types::ErrorTracking::SentryErrorStatusEnum, null: false, - description: 'Status of the error' + description: 'Status of the error.' field :frequency, [Types::ErrorTracking::SentryErrorFrequencyType], null: false, - description: 'Last 24hr stats of the error' + description: 'Last 24hr stats of the error.' field :sentry_project_id, GraphQL::ID_TYPE, method: :project_id, null: false, - description: 'ID of the project (Sentry project)' + description: 'ID of the project (Sentry project).' field :sentry_project_name, GraphQL::STRING_TYPE, method: :project_name, null: false, - description: 'Name of the project affected by the error' + description: 'Name of the project affected by the error.' field :sentry_project_slug, GraphQL::STRING_TYPE, method: :project_slug, null: false, - description: 'Slug of the project affected by the error' + description: 'Slug of the project affected by the error.' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/evidence_type.rb b/app/graphql/types/evidence_type.rb index a2fc9953c67..6e56ad7d407 100644 --- a/app/graphql/types/evidence_type.rb +++ b/app/graphql/types/evidence_type.rb @@ -10,12 +10,12 @@ module Types present_using Releases::EvidencePresenter field :id, GraphQL::ID_TYPE, null: false, - description: 'ID of the evidence' + description: 'ID of the evidence.' field :sha, GraphQL::STRING_TYPE, null: true, - description: 'SHA1 ID of the evidence hash' + description: 'SHA1 ID of the evidence hash.' field :filepath, GraphQL::STRING_TYPE, null: true, - description: 'URL from where the evidence can be downloaded' + description: 'URL from where the evidence can be downloaded.' field :collected_at, Types::TimeType, null: true, - description: 'Timestamp when the evidence was collected' + description: 'Timestamp when the evidence was collected.' end end diff --git a/app/graphql/types/global_id_type.rb b/app/graphql/types/global_id_type.rb index 4c51d4248dd..ed28c3ffd7e 100644 --- a/app/graphql/types/global_id_type.rb +++ b/app/graphql/types/global_id_type.rb @@ -46,7 +46,7 @@ module Types @id_types[model_class] ||= Class.new(self) do graphql_name "#{model_class.name.gsub(/::/, '')}ID" - description "Identifier of #{model_class.name}" + description "Identifier of #{model_class.name}." self.define_singleton_method(:to_s) do graphql_name diff --git a/app/graphql/types/grafana_integration_type.rb b/app/graphql/types/grafana_integration_type.rb index 6625af36f82..630d3a10e36 100644 --- a/app/graphql/types/grafana_integration_type.rb +++ b/app/graphql/types/grafana_integration_type.rb @@ -7,14 +7,14 @@ module Types authorize :admin_operations field :id, GraphQL::ID_TYPE, null: false, - description: 'Internal ID of the Grafana integration' + description: 'Internal ID of the Grafana integration.' field :grafana_url, GraphQL::STRING_TYPE, null: false, - description: 'URL for the Grafana host for the Grafana integration' + description: 'URL for the Grafana host for the Grafana integration.' field :enabled, GraphQL::BOOLEAN_TYPE, null: false, - description: 'Indicates whether Grafana integration is enabled' + description: 'Indicates whether Grafana integration is enabled.' field :created_at, Types::TimeType, null: false, - description: 'Timestamp of the issue\'s creation' + description: 'Timestamp of the issue\'s creation.' field :updated_at, Types::TimeType, null: false, - description: 'Timestamp of the issue\'s last activity' + description: 'Timestamp of the issue\'s last activity.' end end diff --git a/app/graphql/types/group_invitation_type.rb b/app/graphql/types/group_invitation_type.rb index efb0c8a41c8..06a997bbc14 100644 --- a/app/graphql/types/group_invitation_type.rb +++ b/app/graphql/types/group_invitation_type.rb @@ -11,7 +11,7 @@ module Types description 'Represents a Group Invitation' field :group, Types::GroupType, null: true, - description: 'Group that a User is invited to' + description: 'Group that a User is invited to.' def group Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, object.source_id).find diff --git a/app/graphql/types/group_member_type.rb b/app/graphql/types/group_member_type.rb index 204da5a302a..8b8e69d795d 100644 --- a/app/graphql/types/group_member_type.rb +++ b/app/graphql/types/group_member_type.rb @@ -11,7 +11,7 @@ module Types description 'Represents a Group Membership' field :group, Types::GroupType, null: true, - description: 'Group that a User is a member of' + description: 'Group that a User is a member of.' def group Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, object.source_id).find diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index 0ee8a19c1a3..42391ec1d98 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -9,91 +9,91 @@ module Types expose_permissions Types::PermissionTypes::Group field :web_url, GraphQL::STRING_TYPE, null: false, - description: 'Web URL of the group' + description: 'Web URL of the group.' field :avatar_url, GraphQL::STRING_TYPE, null: true, - description: 'Avatar URL of the group' + description: 'Avatar URL of the group.' field :custom_emoji, Types::CustomEmojiType.connection_type, null: true, - description: 'Custom emoji within this namespace', + description: 'Custom emoji within this namespace.', feature_flag: :custom_emoji field :share_with_group_lock, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates if sharing a project with another group within this group is prevented' + description: 'Indicates if sharing a project with another group within this group is prevented.' field :project_creation_level, GraphQL::STRING_TYPE, null: true, method: :project_creation_level_str, - description: 'The permission level required to create projects in the group' + description: 'The permission level required to create projects in the group.' field :subgroup_creation_level, GraphQL::STRING_TYPE, null: true, method: :subgroup_creation_level_str, - description: 'The permission level required to create subgroups within the group' + description: 'The permission level required to create subgroups within the group.' field :require_two_factor_authentication, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates if all users in this group are required to set up two-factor authentication' + description: 'Indicates if all users in this group are required to set up two-factor authentication.' field :two_factor_grace_period, GraphQL::INT_TYPE, null: true, - description: 'Time before two-factor authentication is enforced' + description: 'Time before two-factor authentication is enforced.' field :auto_devops_enabled, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates whether Auto DevOps is enabled for all projects within this group' + description: 'Indicates whether Auto DevOps is enabled for all projects within this group.' field :emails_disabled, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates if a group has email notifications disabled' + description: 'Indicates if a group has email notifications disabled.' field :mentions_disabled, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates if a group is disabled from getting mentioned' + description: 'Indicates if a group is disabled from getting mentioned.' field :parent, GroupType, null: true, - description: 'Parent group' + description: 'Parent group.' field :issues, Types::IssueType.connection_type, null: true, - description: 'Issues for projects in this group', + description: 'Issues for projects in this group.', resolver: Resolvers::GroupIssuesResolver field :merge_requests, Types::MergeRequestType.connection_type, null: true, - description: 'Merge requests for projects in this group', + description: 'Merge requests for projects in this group.', resolver: Resolvers::GroupMergeRequestsResolver field :milestones, Types::MilestoneType.connection_type, null: true, - description: 'Milestones of the group', + description: 'Milestones of the group.', resolver: Resolvers::GroupMilestonesResolver field :boards, Types::BoardType.connection_type, null: true, - description: 'Boards of the group', + description: 'Boards of the group.', max_page_size: 2000, resolver: Resolvers::BoardsResolver field :board, Types::BoardType, null: true, - description: 'A single board of the group', + description: 'A single board of the group.', resolver: Resolvers::BoardResolver field :label, Types::LabelType, null: true, - description: 'A label available on this group' do + description: 'A label available on this group.' do argument :title, GraphQL::STRING_TYPE, required: true, - description: 'Title of the label' + description: 'Title of the label.' end field :group_members, - description: 'A membership of a user within this group', + description: 'A membership of a user within this group.', resolver: Resolvers::GroupMembersResolver field :container_repositories, Types::ContainerRepositoryType.connection_type, null: true, - description: 'Container repositories of the group', + description: 'Container repositories of the group.', resolver: Resolvers::ContainerRepositoriesResolver, authorize: :read_container_image field :container_repositories_count, GraphQL::INT_TYPE, null: false, - description: 'Number of container repositories in the group' + description: 'Number of container repositories in the group.' def label(title:) BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args| @@ -107,10 +107,10 @@ module Types field :labels, Types::LabelType.connection_type, null: true, - description: 'Labels available on this group' do + description: 'Labels available on this group.' do argument :search_term, GraphQL::STRING_TYPE, required: false, - description: 'A search term to find labels with' + description: 'A search term to find labels with.' end def labels(search_term: nil) diff --git a/app/graphql/types/merge_request_state_enum.rb b/app/graphql/types/merge_request_state_enum.rb index 92f52726ab3..c14b9f80a53 100644 --- a/app/graphql/types/merge_request_state_enum.rb +++ b/app/graphql/types/merge_request_state_enum.rb @@ -5,6 +5,6 @@ module Types graphql_name 'MergeRequestState' description 'State of a GitLab merge request' - value 'merged' + value 'merged', description: "Merge Request has been merged" end end diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index ee7d5780f7a..62b3e174a9f 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -152,7 +152,7 @@ module Types end field :task_completion_status, Types::TaskCompletionStatus, null: false, description: Types::TaskCompletionStatus.description - field :commit_count, GraphQL::INT_TYPE, null: true, + field :commit_count, GraphQL::INT_TYPE, null: true, method: :commits_count, description: 'Number of commits in the merge request' field :conflicts, GraphQL::BOOLEAN_TYPE, null: false, method: :cannot_be_merged?, description: 'Indicates if the merge request has conflicts' @@ -218,10 +218,6 @@ module Types BatchLoaders::MergeRequestDiffSummaryBatchLoader.load_for(object) end - def commit_count - object&.metrics&.commits_count - end - def source_branch_protected object.source_project.present? && ProtectedBranch.protected?(object.source_project, object.source_branch) end diff --git a/app/graphql/types/milestone_state_enum.rb b/app/graphql/types/milestone_state_enum.rb index 032571ac88f..e3b60395c9b 100644 --- a/app/graphql/types/milestone_state_enum.rb +++ b/app/graphql/types/milestone_state_enum.rb @@ -2,7 +2,10 @@ module Types class MilestoneStateEnum < BaseEnum - value 'active' - value 'closed' + graphql_name 'MilestoneStateEnum' + description 'Current state of milestone' + + value 'active', description: 'Milestone is currently active' + value 'closed', description: 'Milestone is closed' end end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index f9dd11cbe37..166f5617da2 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -15,6 +15,7 @@ module Types mount_mutation Mutations::AlertManagement::HttpIntegration::Update mount_mutation Mutations::AlertManagement::HttpIntegration::ResetToken mount_mutation Mutations::AlertManagement::HttpIntegration::Destroy + mount_mutation Mutations::Security::CiConfiguration::ConfigureSast mount_mutation Mutations::AlertManagement::PrometheusIntegration::Create mount_mutation Mutations::AlertManagement::PrometheusIntegration::Update mount_mutation Mutations::AlertManagement::PrometheusIntegration::ResetToken @@ -50,6 +51,7 @@ module Types mount_mutation Mutations::MergeRequests::SetSubscription mount_mutation Mutations::MergeRequests::SetWip, calls_gitaly: true mount_mutation Mutations::MergeRequests::SetAssignees + mount_mutation Mutations::MergeRequests::ReviewerRereview mount_mutation Mutations::Metrics::Dashboard::Annotations::Create mount_mutation Mutations::Metrics::Dashboard::Annotations::Delete mount_mutation Mutations::Notes::Create::Note, calls_gitaly: true @@ -97,5 +99,4 @@ module Types end ::Types::MutationType.prepend(::Types::DeprecatedMutations) -::Types::MutationType.prepend_if_ee('EE::Types::DeprecatedMutations') ::Types::MutationType.prepend_if_ee('::EE::Types::MutationType') diff --git a/app/graphql/types/notes/discussion_type.rb b/app/graphql/types/notes/discussion_type.rb index a51d253097d..9b863990849 100644 --- a/app/graphql/types/notes/discussion_type.rb +++ b/app/graphql/types/notes/discussion_type.rb @@ -3,24 +3,26 @@ module Types module Notes class DiscussionType < BaseObject + DiscussionID = ::Types::GlobalIDType[::Discussion] + graphql_name 'Discussion' authorize :read_note implements(Types::ResolvableInterface) - field :id, GraphQL::ID_TYPE, null: false, + field :id, DiscussionID, null: false, description: "ID of this discussion" - field :reply_id, GraphQL::ID_TYPE, null: false, + field :reply_id, DiscussionID, null: false, description: 'ID used to reply to this discussion' field :created_at, Types::TimeType, null: false, description: "Timestamp of the discussion's creation" field :notes, Types::Notes::NoteType.connection_type, null: false, description: 'All notes in the discussion' - # The gem we use to generate Global IDs is hard-coded to work with - # `id` properties. To generate a GID for the `reply_id` property, - # we must use the ::Gitlab::GlobalId module. + # DiscussionID.coerce_result is suitable here, but will always mark this + # as being a 'Discussion'. Using `GlobalId.build` guarantees that we get + # the correct class, and that it matches `id`. def reply_id ::Gitlab::GlobalId.build(object, id: object.reply_id) end diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb index 84b61340e93..dea55fe7f9e 100644 --- a/app/graphql/types/notes/note_type.rb +++ b/app/graphql/types/notes/note_type.rb @@ -11,7 +11,7 @@ module Types implements(Types::ResolvableInterface) - field :id, GraphQL::ID_TYPE, null: false, + field :id, ::Types::GlobalIDType[::Note], null: false, description: 'ID of the note' field :project, Types::ProjectType, diff --git a/app/graphql/types/packages/composer/details_type.rb b/app/graphql/types/packages/composer/details_type.rb deleted file mode 100644 index 8c6845a6fb3..00000000000 --- a/app/graphql/types/packages/composer/details_type.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -module Types - module Packages - module Composer - class DetailsType < Types::Packages::PackageType - graphql_name 'PackageComposerDetails' - description 'Details of a Composer package' - - authorize :read_package - - field :composer_metadatum, Types::Packages::Composer::MetadatumType, null: false, description: 'The Composer metadatum.' - end - end - end -end diff --git a/app/graphql/types/packages/composer/metadatum_type.rb b/app/graphql/types/packages/composer/metadatum_type.rb index a97818b1fb8..9d4ce3cebd4 100644 --- a/app/graphql/types/packages/composer/metadatum_type.rb +++ b/app/graphql/types/packages/composer/metadatum_type.rb @@ -4,8 +4,8 @@ module Types module Packages module Composer class MetadatumType < BaseObject - graphql_name 'PackageComposerMetadatumType' - description 'Composer metadatum' + graphql_name 'ComposerMetadata' + description 'Composer metadata' authorize :read_package diff --git a/app/graphql/types/packages/metadata_type.rb b/app/graphql/types/packages/metadata_type.rb new file mode 100644 index 00000000000..26c43b51a69 --- /dev/null +++ b/app/graphql/types/packages/metadata_type.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Types + module Packages + class MetadataType < BaseUnion + graphql_name 'PackageMetadata' + description 'Represents metadata associated with a Package' + + possible_types ::Types::Packages::Composer::MetadatumType + + def self.resolve_type(object, context) + case object + when ::Packages::Composer::Metadatum + ::Types::Packages::Composer::MetadatumType + else + # NOTE: This method must be kept in sync with `PackageWithoutVersionsType#metadata`, + # which must never produce data that this discriminator cannot handle. + raise 'Unsupported metadata type' + end + end + end + end +end diff --git a/app/graphql/types/packages/package_type.rb b/app/graphql/types/packages/package_type.rb index b13d16e91c6..331898a1e84 100644 --- a/app/graphql/types/packages/package_type.rb +++ b/app/graphql/types/packages/package_type.rb @@ -2,26 +2,13 @@ module Types module Packages - class PackageType < BaseObject + class PackageType < PackageWithoutVersionsType graphql_name 'Package' description 'Represents a package in the Package Registry' - authorize :read_package - field :id, GraphQL::ID_TYPE, null: false, description: 'The ID of the package.' - field :name, GraphQL::STRING_TYPE, null: false, description: 'The name of the package.' - field :created_at, Types::TimeType, null: false, description: 'The created date.' - field :updated_at, Types::TimeType, null: false, description: 'The updated date.' - field :version, GraphQL::STRING_TYPE, null: true, description: 'The version of the package.' - field :package_type, Types::Packages::PackageTypeEnum, null: false, description: 'The type of the package.' - field :tags, Types::Packages::PackageTagType.connection_type, null: true, description: 'The package tags.' - field :project, Types::ProjectType, null: false, description: 'Project where the package is stored.' - field :pipelines, Types::Ci::PipelineType.connection_type, null: true, description: 'Pipelines that built the package.' - field :versions, Types::Packages::PackageType.connection_type, null: true, description: 'The other versions of the package.' - - def project - Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find - end + field :versions, ::Types::Packages::PackageWithoutVersionsType.connection_type, null: true, + description: 'The other versions of the package.' end end end diff --git a/app/graphql/types/packages/package_without_versions_type.rb b/app/graphql/types/packages/package_without_versions_type.rb new file mode 100644 index 00000000000..9c6bb37e6cc --- /dev/null +++ b/app/graphql/types/packages/package_without_versions_type.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Types + module Packages + class PackageWithoutVersionsType < ::Types::BaseObject + graphql_name 'PackageWithoutVersions' + description 'Represents a version of a package in the Package Registry' + + authorize :read_package + + field :id, ::Types::GlobalIDType[::Packages::Package], null: false, + description: 'ID of the package.' + + field :name, GraphQL::STRING_TYPE, null: false, description: 'Name of the package.' + field :created_at, Types::TimeType, null: false, description: 'Date of creation.' + field :updated_at, Types::TimeType, null: false, description: 'Date of most recent update.' + field :version, GraphQL::STRING_TYPE, null: true, description: 'Version string.' + field :package_type, Types::Packages::PackageTypeEnum, null: false, description: 'Package type.' + field :tags, Types::Packages::PackageTagType.connection_type, null: true, description: 'Package tags.' + field :project, Types::ProjectType, null: false, description: 'Project where the package is stored.' + field :pipelines, Types::Ci::PipelineType.connection_type, null: true, + description: 'Pipelines that built the package.' + field :metadata, Types::Packages::MetadataType, null: true, + description: 'Package metadata.' + + def project + Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find + end + + # NOTE: This method must be kept in sync with the union + # type: `Types::Packages::MetadataType`. + # + # `Types::Packages::MetadataType.resolve_type(metadata, ctx)` must never raise. + def metadata + case object.package_type + when 'composer' + object.composer_metadatum + else + nil + end + end + end + end +end diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index f66d8926a9f..20dbbe0987b 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -16,6 +16,10 @@ module Types field :path, GraphQL::STRING_TYPE, null: false, description: 'Path of the project' + field :sast_ci_configuration, Types::CiConfiguration::Sast::Type, null: true, + calls_gitaly: true, + description: 'SAST CI configuration for the project' + field :name_with_namespace, GraphQL::STRING_TYPE, null: false, description: 'Full name of the project with its namespace' field :name, GraphQL::STRING_TYPE, null: false, @@ -108,7 +112,7 @@ module Types field :suggestion_commit_message, GraphQL::STRING_TYPE, null: true, description: 'The commit message used to apply merge request suggestions' field :squash_read_only, GraphQL::BOOLEAN_TYPE, null: false, method: :squash_readonly?, - description: 'Indicates if squash readonly is enabled' + description: 'Indicates if `squashReadOnly` is enabled' field :namespace, Types::NamespaceType, null: true, description: 'Namespace of the project' @@ -175,7 +179,7 @@ module Types description: 'A single issue of the project', resolver: Resolvers::IssuesResolver.single - field :packages, Types::Packages::PackageType.connection_type, null: true, + field :packages, description: 'Packages of the project', resolver: Resolvers::PackagesResolver @@ -305,10 +309,16 @@ module Types description: 'Title of the label' end + field :terraform_state, + Types::Terraform::StateType, + null: true, + description: 'Find a single Terraform state by name.', + resolver: Resolvers::Terraform::StatesResolver.single + field :terraform_states, Types::Terraform::StateType.connection_type, null: true, - description: 'Terraform states associated with the project', + description: 'Terraform states associated with the project.', resolver: Resolvers::Terraform::StatesResolver field :pipeline_analytics, Types::Ci::AnalyticsType, null: true, @@ -359,6 +369,12 @@ module Types project.container_repositories.size end + def sast_ci_configuration + return unless Ability.allowed?(current_user, :download_code, object) + + ::Security::CiConfiguration::SastParserService.new(object).configuration + end + private def project diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 0e0c060f374..69991b6413a 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -58,9 +58,8 @@ module Types argument :id, ::Types::GlobalIDType[::ContainerRepository], required: true, description: 'The global ID of the container repository' end - field :package_composer_details, Types::Packages::Composer::DetailsType, - null: true, - description: 'Find a composer package', + field :package, + description: 'Find a package', resolver: Resolvers::PackageDetailsResolver field :user, Types::UserType, diff --git a/app/graphql/types/snippets/blob_viewer_type.rb b/app/graphql/types/snippets/blob_viewer_type.rb index a2ffa144066..5827e3eeae9 100644 --- a/app/graphql/types/snippets/blob_viewer_type.rb +++ b/app/graphql/types/snippets/blob_viewer_type.rb @@ -11,7 +11,7 @@ module Types null: false field :load_async, GraphQL::BOOLEAN_TYPE, - description: 'Shows whether the blob content is loaded async', + description: 'Shows whether the blob content is loaded asynchronously', null: false field :collapsed, GraphQL::BOOLEAN_TYPE, diff --git a/app/graphql/types/todo_type.rb b/app/graphql/types/todo_type.rb index 3694980ef93..4cf2dbcab9e 100644 --- a/app/graphql/types/todo_type.rb +++ b/app/graphql/types/todo_type.rb @@ -3,49 +3,49 @@ module Types class TodoType < BaseObject graphql_name 'Todo' - description 'Representing a todo entry' + description 'Representing a to-do entry' present_using TodoPresenter authorize :read_todo field :id, GraphQL::ID_TYPE, - description: 'ID of the todo', + description: 'ID of the to-do item', null: false field :project, Types::ProjectType, - description: 'The project this todo is associated with', + description: 'The project this to-do item is associated with', null: true, authorize: :read_project field :group, Types::GroupType, - description: 'Group this todo is associated with', + description: 'Group this to-do item is associated with', null: true, authorize: :read_group field :author, Types::UserType, - description: 'The author of this todo', + description: 'The author of this to-do item', null: false field :action, Types::TodoActionEnum, - description: 'Action of the todo', + description: 'Action of the to-do item', null: false field :target_type, Types::TodoTargetEnum, - description: 'Target type of the todo', + description: 'Target type of the to-do item', null: false field :body, GraphQL::STRING_TYPE, - description: 'Body of the todo', + description: 'Body of the to-do item', null: false, calls_gitaly: true # TODO This is only true when `target_type` is `Commit`. See https://gitlab.com/gitlab-org/gitlab/issues/34757#note_234752665 field :state, Types::TodoStateEnum, - description: 'State of the todo', + description: 'State of the to-do item', null: false field :created_at, Types::TimeType, - description: 'Timestamp this todo was created', + description: 'Timestamp this to-do item was created', null: false def project diff --git a/app/graphql/types/tree/entry_type.rb b/app/graphql/types/tree/entry_type.rb index b40e38ec9d1..5e4cace2e98 100644 --- a/app/graphql/types/tree/entry_type.rb +++ b/app/graphql/types/tree/entry_type.rb @@ -7,7 +7,7 @@ module Types field :id, GraphQL::ID_TYPE, null: false, description: 'ID of the entry' field :sha, GraphQL::STRING_TYPE, null: false, - description: 'Last commit sha for the entry', method: :id + description: 'Last commit SHA for the entry', method: :id field :name, GraphQL::STRING_TYPE, null: false, description: 'Name of the entry' field :type, Tree::TypeEnum, null: false, diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb index 93503268319..c179c84ba84 100644 --- a/app/graphql/types/user_type.rb +++ b/app/graphql/types/user_type.rb @@ -31,7 +31,7 @@ module Types description: 'Web path of the user' field :todos, Types::TodoType.connection_type, null: false, resolver: Resolvers::TodoResolver, - description: 'Todos of the user' + description: 'To-do items of the user' field :group_memberships, Types::GroupMemberType.connection_type, null: true, description: 'Group memberships of the user' field :group_count, GraphQL::INT_TYPE, null: true, |