diff options
Diffstat (limited to 'app/graphql/types')
20 files changed, 239 insertions, 31 deletions
diff --git a/app/graphql/types/ci/ci_cd_setting_type.rb b/app/graphql/types/ci/ci_cd_setting_type.rb index bec8c72e783..574791b79e6 100644 --- a/app/graphql/types/ci/ci_cd_setting_type.rb +++ b/app/graphql/types/ci/ci_cd_setting_type.rb @@ -10,8 +10,17 @@ module Types field :job_token_scope_enabled, GraphQL::Types::Boolean, null: true, - description: 'Indicates CI job tokens generated in this project have restricted access to resources.', + description: 'Indicates CI/CD job tokens generated in this project ' \ + 'have restricted access to other projects.', method: :job_token_scope_enabled? + + field :inbound_job_token_scope_enabled, + GraphQL::Types::Boolean, + null: true, + description: 'Indicates CI/CD job tokens generated in other projects ' \ + 'have restricted access to this project.', + method: :inbound_job_token_scope_enabled? + field :keep_latest_artifact, GraphQL::Types::Boolean, null: true, description: 'Whether to keep the latest builds artifacts.', method: :keep_latest_artifacts_available? diff --git a/app/graphql/types/ci/config_variable_type.rb b/app/graphql/types/ci/config_variable_type.rb index 87ae026c2c1..5b5890fd5a5 100644 --- a/app/graphql/types/ci/config_variable_type.rb +++ b/app/graphql/types/ci/config_variable_type.rb @@ -17,6 +17,10 @@ module Types field :value, GraphQL::Types::String, null: true, description: 'Value of the variable.' + + field :value_options, [GraphQL::Types::String], + null: true, + description: 'Value options for the variable.' end end end diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index ab6103d9469..4447a10a74e 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -56,6 +56,8 @@ module Types description: 'Indicates the job is active.' field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, description: 'Artifacts generated by the job.' + field :browse_artifacts_path, GraphQL::Types::String, null: true, + description: "URL for browsing the artifact's archive." field :cancelable, GraphQL::Types::Boolean, null: false, method: :cancelable?, description: 'Indicates the job can be canceled.' field :commit_path, GraphQL::Types::String, null: true, @@ -148,17 +150,7 @@ module Types end def stage - ::Gitlab::Graphql::Lazy.with_value(pipeline) do |pl| - BatchLoader::GraphQL.for([pl, object.stage]).batch do |ids, loader| - by_pipeline = ids - .group_by(&:first) - .transform_values { |grp| grp.map(&:second) } - - by_pipeline.each do |p, names| - p.stages.by_name(names).each { |s| loader.call([p, s.name], s) } - end - end - end + ::Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Stage, object.stage_id).find end # This class is a secret union! @@ -187,6 +179,10 @@ module Types ::Gitlab::Routing.url_helpers.project_job_path(object.project, object) end + def browse_artifacts_path + ::Gitlab::Routing.url_helpers.browse_project_job_artifacts_path(object.project, object) + end + def coverage object&.coverage end diff --git a/app/graphql/types/ci/pipeline_schedule_status_enum.rb b/app/graphql/types/ci/pipeline_schedule_status_enum.rb new file mode 100644 index 00000000000..61bae7daff8 --- /dev/null +++ b/app/graphql/types/ci/pipeline_schedule_status_enum.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Types + module Ci + class PipelineScheduleStatusEnum < BaseEnum + graphql_name 'PipelineScheduleStatus' + + value 'ACTIVE', value: "active", description: 'Active pipeline schedules.' + value 'INACTIVE', value: "inactive", description: 'Inactive pipeline schedules.' + end + end +end diff --git a/app/graphql/types/ci/pipeline_schedule_type.rb b/app/graphql/types/ci/pipeline_schedule_type.rb new file mode 100644 index 00000000000..04f9fc78a92 --- /dev/null +++ b/app/graphql/types/ci/pipeline_schedule_type.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Types + module Ci + class PipelineScheduleType < BaseObject + graphql_name 'PipelineSchedule' + + connection_type_class(Types::CountableConnectionType) + + expose_permissions Types::PermissionTypes::Ci::PipelineSchedules + + authorize :read_pipeline_schedule + + field :id, GraphQL::Types::ID, null: false, description: 'ID of the pipeline schedule.' + + field :description, GraphQL::Types::String, null: true, description: 'Description of the pipeline schedule.' + + field :owner, ::Types::UserType, null: false, description: 'Owner of the pipeline schedule.' + + field :active, GraphQL::Types::Boolean, null: false, description: 'Indicates if a pipeline schedule is active.' + + field :next_run_at, Types::TimeType, null: false, description: 'Time when the next pipeline will run.' + + field :real_next_run, Types::TimeType, null: false, description: 'Time when the next pipeline will run.' + + field :last_pipeline, PipelineType, null: true, description: 'Last pipeline object.' + + field :ref_for_display, GraphQL::Types::String, + null: true, description: 'Git ref for the pipeline schedule.', method: :ref_for_display + + field :ref_path, GraphQL::Types::String, null: true, description: 'Path to the ref that triggered the pipeline.' + + field :for_tag, GraphQL::Types::Boolean, + null: false, description: 'Indicates if a pipelines schedule belongs to a tag.', method: :for_tag? + + field :cron, GraphQL::Types::String, null: false, description: 'Cron notation for the schedule.' + + field :cron_timezone, GraphQL::Types::String, null: false, description: 'Timezone for the pipeline schedule.' + + def ref_path + ::Gitlab::Routing.url_helpers.project_commits_path(object.project, object.ref_for_display) + end + end + end +end diff --git a/app/graphql/types/ci/runner_membership_filter_enum.rb b/app/graphql/types/ci/runner_membership_filter_enum.rb index 4fd7e0749b0..d59a68b427b 100644 --- a/app/graphql/types/ci/runner_membership_filter_enum.rb +++ b/app/graphql/types/ci/runner_membership_filter_enum.rb @@ -15,6 +15,13 @@ module Types description: "Include runners that have either a direct or inherited relationship. " \ "These runners can be specific to a project or a group.", value: :descendants + + value 'ALL_AVAILABLE', + description: + "Include all runners. This list includes runners for all projects in the group " \ + "and subgroups, as well as for the parent groups and instance.", + value: :all_available, + deprecated: { milestone: '15.5', reason: :alpha } end end end diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index eb4e7b1dabf..dd2286d333d 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -57,7 +57,7 @@ module Types field :deployments, Types::DeploymentType.connection_type, null: true, - description: 'Deployments of the environment. This field can only be resolved for one project in any single request.', + description: 'Deployments of the environment. This field can only be resolved for one environment in any single request.', resolver: Resolvers::DeploymentsResolver do extension ::Gitlab::Graphql::Limit::FieldCallCount, limit: 1 end @@ -72,3 +72,5 @@ module Types end end end + +Types::EnvironmentType.prepend_mod_with('Types::EnvironmentType') diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb index d897f3cde48..76fac831199 100644 --- a/app/graphql/types/issue_type.rb +++ b/app/graphql/types/issue_type.rb @@ -43,8 +43,10 @@ module Types field :updated_by, Types::UserType, null: true, description: 'User that last updated the issue.' - field :labels, Types::LabelType.connection_type, null: true, - description: 'Labels of the issue.' + field :labels, Types::LabelType.connection_type, + null: true, + description: 'Labels of the issue.', + resolver: Resolvers::BulkLabelsResolver field :milestone, Types::MilestoneType, null: true, description: 'Milestone of the issue.' @@ -58,15 +60,20 @@ module Types description: 'Indicates the issue is hidden because the author has been banned. ' \ 'Will always return `null` if `ban_user_feature_flag` feature flag is disabled.' - field :downvotes, GraphQL::Types::Int, null: false, - description: 'Number of downvotes the issue has received.' + field :downvotes, GraphQL::Types::Int, + null: false, + description: 'Number of downvotes the issue has received.', + resolver: Resolvers::DownVotesCountResolver field :merge_requests_count, GraphQL::Types::Int, null: false, description: 'Number of merge requests that close the issue on merge.', resolver: Resolvers::MergeRequestsCountResolver field :relative_position, GraphQL::Types::Int, null: true, description: 'Relative position of the issue (used for positioning in epic tree and issue boards).' - field :upvotes, GraphQL::Types::Int, null: false, - description: 'Number of upvotes the issue has received.' + field :upvotes, GraphQL::Types::Int, + null: false, + description: 'Number of upvotes the issue has received.', + resolver: Resolvers::UpVotesCountResolver + field :user_discussions_count, GraphQL::Types::Int, null: false, description: 'Number of user discussions in the issue.', resolver: Resolvers::UserDiscussionsCountResolver diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index 399dcc8e03d..8cc600fc68e 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -75,8 +75,12 @@ module Types null: false, calls_gitaly: true, method: :diverged_from_target_branch?, description: 'Indicates if the source branch is behind the target branch.' - field :downvotes, GraphQL::Types::Int, null: false, - description: 'Number of downvotes for the merge request.' + + field :downvotes, GraphQL::Types::Int, + null: false, + description: 'Number of downvotes for the merge request.', + resolver: Resolvers::DownVotesCountResolver + field :force_remove_source_branch, GraphQL::Types::Boolean, method: :force_remove_source_branch?, null: true, description: 'Indicates if the project settings will lead to source branch deletion after merge.' field :in_progress_merge_commit_sha, GraphQL::Types::String, null: true, @@ -118,8 +122,12 @@ module Types null: false, calls_gitaly: true, method: :target_branch_exists?, description: 'Indicates if the target branch of the merge request exists.' - field :upvotes, GraphQL::Types::Int, null: false, - description: 'Number of upvotes for the merge request.' + + field :upvotes, GraphQL::Types::Int, + null: false, + description: 'Number of upvotes for the merge request.', + resolver: Resolvers::UpVotesCountResolver + field :user_discussions_count, GraphQL::Types::Int, null: true, description: 'Number of user discussions in the merge request.', resolver: Resolvers::UserDiscussionsCountResolver @@ -150,8 +158,11 @@ module Types description: 'Human-readable time estimate of the merge request.' field :human_total_time_spent, GraphQL::Types::String, null: true, description: 'Human-readable total time reported as spent on the merge request.' - field :labels, Types::LabelType.connection_type, null: true, complexity: 5, - description: 'Labels of the merge request.' + field :labels, Types::LabelType.connection_type, + null: true, complexity: 5, + description: 'Labels of the merge request.', + resolver: Resolvers::BulkLabelsResolver + field :milestone, Types::MilestoneType, null: true, description: 'Milestone of the merge request.' field :participants, Types::MergeRequests::ParticipantType.connection_type, null: true, complexity: 15, diff --git a/app/graphql/types/merge_requests/detailed_merge_status_enum.rb b/app/graphql/types/merge_requests/detailed_merge_status_enum.rb index 3de6296154d..1ba72ae33b5 100644 --- a/app/graphql/types/merge_requests/detailed_merge_status_enum.rb +++ b/app/graphql/types/merge_requests/detailed_merge_status_enum.rb @@ -42,6 +42,9 @@ module Types value 'POLICIES_DENIED', value: :policies_denied, description: 'There are denied policies for the merge request.' + value 'EXTERNAL_STATUS_CHECKS', + value: :status_checks_must_pass, + description: 'Status checks must pass.' end end end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index ea833b35085..5ffc1aeacad 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -114,6 +114,7 @@ module Types mount_mutation Mutations::Ci::Pipeline::Cancel mount_mutation Mutations::Ci::Pipeline::Destroy mount_mutation Mutations::Ci::Pipeline::Retry + mount_mutation Mutations::Ci::PipelineSchedule::Delete mount_mutation Mutations::Ci::CiCdSettingsUpdate, deprecated: { reason: :renamed, replacement: 'ProjectCiCdSettingsUpdate', @@ -137,6 +138,8 @@ module Types mount_mutation Mutations::UserCallouts::Create mount_mutation Mutations::UserPreferences::Update mount_mutation Mutations::Packages::Destroy + mount_mutation Mutations::Packages::BulkDestroy, + extensions: [::Gitlab::Graphql::Limit::FieldCallCount => { limit: 1 }] mount_mutation Mutations::Packages::DestroyFile mount_mutation Mutations::Packages::DestroyFiles mount_mutation Mutations::Packages::Cleanup::Policy::Update @@ -146,7 +149,6 @@ module Types mount_mutation Mutations::WorkItems::Delete, alpha: { milestone: '15.1' } mount_mutation Mutations::WorkItems::DeleteTask, alpha: { milestone: '15.1' } mount_mutation Mutations::WorkItems::Update, alpha: { milestone: '15.1' } - mount_mutation Mutations::WorkItems::UpdateWidgets, alpha: { milestone: '15.1' } mount_mutation Mutations::WorkItems::UpdateTask, alpha: { milestone: '15.1' } mount_mutation Mutations::SavedReplies::Create mount_mutation Mutations::SavedReplies::Update diff --git a/app/graphql/types/namespace/package_settings_type.rb b/app/graphql/types/namespace/package_settings_type.rb index 7a0abe619a5..84becba8001 100644 --- a/app/graphql/types/namespace/package_settings_type.rb +++ b/app/graphql/types/namespace/package_settings_type.rb @@ -8,9 +8,50 @@ module Types authorize :admin_package - field :generic_duplicate_exception_regex, Types::UntrustedRegexp, null: true, description: 'When generic_duplicates_allowed is false, you can publish duplicate packages with names that match this regex. Otherwise, this setting has no effect.' - field :generic_duplicates_allowed, GraphQL::Types::Boolean, null: false, description: 'Indicates whether duplicate generic packages are allowed for this namespace.' - field :maven_duplicate_exception_regex, Types::UntrustedRegexp, null: true, description: 'When maven_duplicates_allowed is false, you can publish duplicate packages with names that match this regex. Otherwise, this setting has no effect.' - field :maven_duplicates_allowed, GraphQL::Types::Boolean, null: false, description: 'Indicates whether duplicate Maven packages are allowed for this namespace.' + field :generic_duplicate_exception_regex, Types::UntrustedRegexp, + null: true, + description: 'When generic_duplicates_allowed is false, you can publish duplicate packages with names that match this regex. Otherwise, this setting has no effect.' + field :generic_duplicates_allowed, GraphQL::Types::Boolean, + null: false, + description: 'Indicates whether duplicate generic packages are allowed for this namespace.' + field :maven_duplicate_exception_regex, Types::UntrustedRegexp, + null: true, + description: 'When maven_duplicates_allowed is false, you can publish duplicate packages with names that match this regex. Otherwise, this setting has no effect.' + field :maven_duplicates_allowed, GraphQL::Types::Boolean, + null: false, + description: 'Indicates whether duplicate Maven packages are allowed for this namespace.' + + field :maven_package_requests_forwarding, GraphQL::Types::Boolean, + null: true, + description: 'Indicates whether Maven package forwarding is allowed for this namespace.' + field :npm_package_requests_forwarding, GraphQL::Types::Boolean, + null: true, + description: 'Indicates whether npm package forwarding is allowed for this namespace.' + field :pypi_package_requests_forwarding, GraphQL::Types::Boolean, + null: true, + description: 'Indicates whether PyPI package forwarding is allowed for this namespace.' + + field :lock_maven_package_requests_forwarding, GraphQL::Types::Boolean, + null: false, + description: 'Indicates whether Maven package forwarding is locked for all descendent namespaces.' + field :lock_npm_package_requests_forwarding, GraphQL::Types::Boolean, + null: false, + description: 'Indicates whether npm package forwarding is locked for all descendent namespaces.' + field :lock_pypi_package_requests_forwarding, GraphQL::Types::Boolean, + null: false, + description: 'Indicates whether PyPI package forwarding is locked for all descendent namespaces.' + + field :maven_package_requests_forwarding_locked, GraphQL::Types::Boolean, + null: false, + method: :maven_package_requests_forwarding_locked?, + description: 'Indicates whether Maven package forwarding settings are locked by a parent namespace.' + field :npm_package_requests_forwarding_locked, GraphQL::Types::Boolean, + null: false, + method: :npm_package_requests_forwarding_locked?, + description: 'Indicates whether npm package forwarding settings are locked by a parent namespace.' + field :pypi_package_requests_forwarding_locked, GraphQL::Types::Boolean, + null: false, + method: :pypi_package_requests_forwarding_locked?, + description: 'Indicates whether PyPI package forwarding settings are locked by a parent namespace.' end end diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb index c254460a51f..eef5ce40bde 100644 --- a/app/graphql/types/notes/note_type.rb +++ b/app/graphql/types/notes/note_type.rb @@ -41,7 +41,7 @@ module Types deprecated: { reason: :renamed, replacement: 'internal', - milestone: '15.3' + milestone: '15.5' } field :internal, GraphQL::Types::Boolean, null: true, diff --git a/app/graphql/types/permission_types/ci/pipeline_schedules.rb b/app/graphql/types/permission_types/ci/pipeline_schedules.rb new file mode 100644 index 00000000000..268ac6096d0 --- /dev/null +++ b/app/graphql/types/permission_types/ci/pipeline_schedules.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Types + module PermissionTypes + module Ci + class PipelineSchedules < BasePermissionType + graphql_name 'PipelineSchedulePermissions' + + abilities :take_ownership_pipeline_schedule, + :update_pipeline_schedule, + :admin_pipeline_schedule + + ability_field :play_pipeline_schedule, calls_gitaly: true + end + end + end +end diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index f43f5c27dac..a41af34ef4c 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -309,6 +309,12 @@ module Types extras: [:lookahead], resolver: Resolvers::ProjectPipelinesResolver + field :pipeline_schedules, + type: Types::Ci::PipelineScheduleType.connection_type, + null: true, + description: 'Pipeline schedules of the project. This field can only be resolved for one project per request.', + resolver: Resolvers::ProjectPipelineSchedulesResolver + field :pipeline, Types::Ci::PipelineType, null: true, description: 'Build pipeline of the project.', diff --git a/app/graphql/types/projects/branch_rule_type.rb b/app/graphql/types/projects/branch_rule_type.rb index 866cff0f439..e7632c17cca 100644 --- a/app/graphql/types/projects/branch_rule_type.rb +++ b/app/graphql/types/projects/branch_rule_type.rb @@ -13,6 +13,13 @@ module Types null: false, description: 'Branch name, with wildcards, for the branch rules.' + field :is_default, + type: GraphQL::Types::Boolean, + null: false, + method: :default_branch?, + calls_gitaly: true, + description: "Check if this branch rule protects the project's default branch." + field :branch_protection, type: Types::BranchRules::BranchProtectionType, null: false, @@ -31,3 +38,5 @@ module Types end end end + +Types::Projects::BranchRuleType.prepend_mod diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 78463a1804a..1b39f43659e 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -154,6 +154,12 @@ module Types null: true, description: "Whether Gitpod is enabled in application settings." + field :jobs, + ::Types::Ci::JobType.connection_type, + null: true, + description: 'All jobs on this GitLab instance.', + resolver: ::Resolvers::Ci::AllJobsResolver + def design_management DesignManagementObject.new(nil) end diff --git a/app/graphql/types/subscription_type.rb b/app/graphql/types/subscription_type.rb index ef701bbfc10..3b8f5c64beb 100644 --- a/app/graphql/types/subscription_type.rb +++ b/app/graphql/types/subscription_type.rb @@ -13,6 +13,9 @@ module Types field :issuable_title_updated, subscription: Subscriptions::IssuableUpdated, null: true, description: 'Triggered when the title of an issuable is updated.' + field :issuable_description_updated, subscription: Subscriptions::IssuableUpdated, null: true, + description: 'Triggered when the description of an issuable is updated.' + field :issuable_labels_updated, subscription: Subscriptions::IssuableUpdated, null: true, description: 'Triggered when the labels of an issuable are updated.' @@ -23,6 +26,11 @@ module Types subscription: Subscriptions::IssuableUpdated, null: true, description: 'Triggered when the reviewers of a merge request are updated.' + + field :merge_request_merge_status_updated, + subscription: Subscriptions::IssuableUpdated, + null: true, + description: 'Triggered when the merge status of a merge request is updated.' end end diff --git a/app/graphql/types/work_items/widget_interface.rb b/app/graphql/types/work_items/widget_interface.rb index eca8c8d845a..a3943361114 100644 --- a/app/graphql/types/work_items/widget_interface.rb +++ b/app/graphql/types/work_items/widget_interface.rb @@ -23,6 +23,9 @@ module Types ORPHAN_TYPES end + # Whenever a new widget is added make sure to update the spec to avoid N + 1 queries in + # spec/requests/api/graphql/project/work_items_spec.rb and add the necessary preloads + # in app/graphql/resolvers/work_items_resolver.rb def self.resolve_type(object, context) case object when ::WorkItems::Widgets::Description diff --git a/app/graphql/types/work_items/widgets/labels_update_input_type.rb b/app/graphql/types/work_items/widgets/labels_update_input_type.rb new file mode 100644 index 00000000000..d38b8cefa63 --- /dev/null +++ b/app/graphql/types/work_items/widgets/labels_update_input_type.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Types + module WorkItems + module Widgets + class LabelsUpdateInputType < BaseInputObject + graphql_name 'WorkItemWidgetLabelsUpdateInput' + + argument :add_label_ids, [Types::GlobalIDType[::Label]], + required: false, + description: 'Global IDs of labels to be added to the work item.', + prepare: ->(label_ids, _ctx) { label_ids.map(&:model_id) } + argument :remove_label_ids, [Types::GlobalIDType[::Label]], + required: false, + description: 'Global IDs of labels to be removed from the work item.', + prepare: ->(label_ids, _ctx) { label_ids.map(&:model_id) } + end + end + end +end |