diff options
Diffstat (limited to 'app/graphql/resolvers')
60 files changed, 234 insertions, 161 deletions
diff --git a/app/graphql/resolvers/admin/analytics/instance_statistics/measurements_resolver.rb b/app/graphql/resolvers/admin/analytics/instance_statistics/measurements_resolver.rb index 9bac9f222ab..9df07df24d8 100644 --- a/app/graphql/resolvers/admin/analytics/instance_statistics/measurements_resolver.rb +++ b/app/graphql/resolvers/admin/analytics/instance_statistics/measurements_resolver.rb @@ -11,15 +11,15 @@ module Resolvers argument :identifier, Types::Admin::Analytics::InstanceStatistics::MeasurementIdentifierEnum, required: true, - description: 'The type of measurement/statistics to retrieve' + description: 'The type of measurement/statistics to retrieve.' argument :recorded_after, Types::TimeType, required: false, - description: 'Measurement recorded after this date' + description: 'Measurement recorded after this date.' argument :recorded_before, Types::TimeType, required: false, - description: 'Measurement recorded before this date' + description: 'Measurement recorded before this date.' def resolve(identifier:, recorded_before: nil, recorded_after: nil) authorize! diff --git a/app/graphql/resolvers/alert_management/alert_resolver.rb b/app/graphql/resolvers/alert_management/alert_resolver.rb index b115bd80113..d60cabde62b 100644 --- a/app/graphql/resolvers/alert_management/alert_resolver.rb +++ b/app/graphql/resolvers/alert_management/alert_resolver.rb @@ -7,19 +7,19 @@ module Resolvers argument :iid, GraphQL::STRING_TYPE, required: false, - description: 'IID of the alert. For example, "1"' + description: 'IID of the alert. For example, "1".' argument :statuses, [Types::AlertManagement::StatusEnum], as: :status, required: false, - description: 'Alerts with the specified statues. For example, [TRIGGERED]' + description: 'Alerts with the specified statues. For example, [TRIGGERED].' argument :sort, Types::AlertManagement::AlertSortEnum, - description: 'Sort alerts by this criteria', + description: 'Sort alerts by this criteria.', required: false argument :domain, Types::AlertManagement::DomainFilterEnum, - description: 'Filter query for given domain', + description: 'Filter query for given domain.', required: true, default_value: 'operations' @@ -29,7 +29,7 @@ module Resolvers argument :assignee_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of a user assigned to the issue' + description: 'Username of a user assigned to the issue.' type Types::AlertManagement::AlertType, null: true diff --git a/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb b/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb index 8fc0f9fd1ff..410f72cff84 100644 --- a/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb +++ b/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :assignee_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of a user assigned to the issue' + description: 'Username of a user assigned to the issue.' def resolve(**args) ::Gitlab::AlertManagement::AlertStatusCounts.new(context[:current_user], object, args) diff --git a/app/graphql/resolvers/board_list_issues_resolver.rb b/app/graphql/resolvers/board_list_issues_resolver.rb index 3e4a5a3cb70..29e66a59a15 100644 --- a/app/graphql/resolvers/board_list_issues_resolver.rb +++ b/app/graphql/resolvers/board_list_issues_resolver.rb @@ -6,7 +6,7 @@ module Resolvers argument :filters, Types::Boards::BoardIssueInputType, required: false, - description: 'Filters applied when selecting issues in the board list' + description: 'Filters applied when selecting issues in the board list.' type Types::IssueType, null: true diff --git a/app/graphql/resolvers/board_lists_resolver.rb b/app/graphql/resolvers/board_lists_resolver.rb index 35d938c50be..7bdff8ba61f 100644 --- a/app/graphql/resolvers/board_lists_resolver.rb +++ b/app/graphql/resolvers/board_lists_resolver.rb @@ -13,11 +13,11 @@ module Resolvers argument :id, Types::GlobalIDType[List], required: false, - description: 'Find a list by its global ID' + description: 'Find a list by its global ID.' argument :issue_filters, Types::Boards::BoardIssueInputType, required: false, - description: 'Filters applied when getting issue metadata in the board list' + description: 'Filters applied when getting issue metadata in the board list.' alias_method :board, :object diff --git a/app/graphql/resolvers/board_resolver.rb b/app/graphql/resolvers/board_resolver.rb index 517f4e514c9..582707cc1e4 100644 --- a/app/graphql/resolvers/board_resolver.rb +++ b/app/graphql/resolvers/board_resolver.rb @@ -8,7 +8,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::Board], required: true, - description: 'The board\'s ID' + description: 'The board\'s ID.' def resolve(id: nil) return unless parent diff --git a/app/graphql/resolvers/boards_resolver.rb b/app/graphql/resolvers/boards_resolver.rb index 42b6ce03118..cdb15dc8f37 100644 --- a/app/graphql/resolvers/boards_resolver.rb +++ b/app/graphql/resolvers/boards_resolver.rb @@ -6,7 +6,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::Board], required: false, - description: 'Find a board by its ID' + description: 'Find a board by its ID.' def resolve(id: nil) # The project or group could have been loaded in batch by `BatchLoader`. diff --git a/app/graphql/resolvers/ci/config_resolver.rb b/app/graphql/resolvers/ci/config_resolver.rb index d6e7c206691..72d3ae30d73 100644 --- a/app/graphql/resolvers/ci/config_resolver.rb +++ b/app/graphql/resolvers/ci/config_resolver.rb @@ -3,40 +3,64 @@ module Resolvers module Ci class ConfigResolver < BaseResolver + include Gitlab::Graphql::Authorize::AuthorizeResource + include ResolvesProject + type Types::Ci::Config::ConfigType, null: true + authorize :read_pipeline + + argument :project_path, GraphQL::ID_TYPE, + required: true, + description: 'The project of the CI config.' + argument :content, GraphQL::STRING_TYPE, required: true, - description: 'Contents of .gitlab-ci.yml' - - def resolve(content:) - result = ::Gitlab::Ci::YamlProcessor.new(content).execute - - response = if result.errors.empty? - { - status: :valid, - errors: [], - stages: make_stages(result.jobs) - } - else - { - status: :invalid, - errors: result.errors - } - end - - response.merge(merged_yaml: result.merged_yaml) + description: "Contents of '.gitlab-ci.yml'." + + argument :dry_run, GraphQL::BOOLEAN_TYPE, + required: false, + description: 'Run pipeline creation simulation, or only do static check.' + + def resolve(project_path:, content:, dry_run: false) + project = authorized_find!(project_path: project_path) + + result = ::Gitlab::Ci::Lint + .new(project: project, current_user: context[:current_user]) + .validate(content, dry_run: dry_run) + + if result.errors.empty? + { + status: :valid, + errors: [], + stages: make_stages(result.jobs) + } + else + { + status: :invalid, + errors: result.errors + } + end end private def make_jobs(config_jobs) - config_jobs.map do |job_name, job| + config_jobs.map do |job| { - name: job_name, + name: job[:name], stage: job[:stage], - group_name: CommitStatus.new(name: job_name).group_name, - needs: job.dig(:needs, :job) || [] + group_name: CommitStatus.new(name: job[:name]).group_name, + needs: job.dig(:needs) || [], + allow_failure: job[:allow_failure], + before_script: job[:before_script], + script: job[:script], + after_script: job[:after_script], + only: job[:only], + except: job[:except], + when: job[:when], + tags: job[:tag_list], + environment: job[:environment] } end end @@ -55,6 +79,10 @@ module Resolvers .group_by { |group| group[:stage] } .map { |name, groups| { name: name, groups: groups } } end + + def find_object(project_path:) + resolve_project(full_path: project_path) + end end end end diff --git a/app/graphql/resolvers/ci/jobs_resolver.rb b/app/graphql/resolvers/ci/jobs_resolver.rb index 2c4911748a5..dd565094017 100644 --- a/app/graphql/resolvers/ci/jobs_resolver.rb +++ b/app/graphql/resolvers/ci/jobs_resolver.rb @@ -9,7 +9,7 @@ module Resolvers argument :security_report_types, [Types::Security::ReportTypeEnum], required: false, - description: 'Filter jobs by the type of security report they produce' + description: 'Filter jobs by the type of security report they produce.' def resolve(security_report_types: []) if security_report_types.present? diff --git a/app/graphql/resolvers/ci/runner_setup_resolver.rb b/app/graphql/resolvers/ci/runner_setup_resolver.rb index f68d71174c3..ac2a56b89a7 100644 --- a/app/graphql/resolvers/ci/runner_setup_resolver.rb +++ b/app/graphql/resolvers/ci/runner_setup_resolver.rb @@ -7,19 +7,19 @@ module Resolvers argument :platform, GraphQL::STRING_TYPE, required: true, - description: 'Platform to generate the instructions for' + description: 'Platform to generate the instructions for.' argument :architecture, GraphQL::STRING_TYPE, required: true, - description: 'Architecture to generate the instructions for' + description: 'Architecture to generate the instructions for.' argument :project_id, ::Types::GlobalIDType[::Project], required: false, - description: 'Project to register the runner for' + description: 'Project to register the runner for.' argument :group_id, ::Types::GlobalIDType[::Group], required: false, - description: 'Group to register the runner for' + description: 'Group to register the runner for.' def resolve(platform:, architecture:, **args) instructions = Gitlab::Ci::RunnerInstructions.new( diff --git a/app/graphql/resolvers/concerns/issue_resolver_arguments.rb b/app/graphql/resolvers/concerns/issue_resolver_arguments.rb index 4715b867ecb..84b0dafe213 100644 --- a/app/graphql/resolvers/concerns/issue_resolver_arguments.rb +++ b/app/graphql/resolvers/concerns/issue_resolver_arguments.rb @@ -8,52 +8,52 @@ module IssueResolverArguments argument :iid, GraphQL::STRING_TYPE, required: false, - description: 'IID of the issue. For example, "1"' + description: 'IID of the issue. For example, "1".' argument :iids, [GraphQL::STRING_TYPE], required: false, - description: 'List of IIDs of issues. For example, [1, 2]' + description: 'List of IIDs of issues. For example, [1, 2].' argument :label_name, GraphQL::STRING_TYPE.to_list_type, required: false, - description: 'Labels applied to this issue' + description: 'Labels applied to this issue.' argument :milestone_title, GraphQL::STRING_TYPE.to_list_type, required: false, - description: 'Milestone applied to this issue' + description: 'Milestone applied to this issue.' argument :author_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of the author of the issue' + description: 'Username of the author of the issue.' argument :assignee_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of a user assigned to the issue' + description: 'Username of a user assigned to the issue.' argument :assignee_usernames, [GraphQL::STRING_TYPE], required: false, - description: 'Usernames of users assigned to the issue' + description: 'Usernames of users assigned to the issue.' argument :assignee_id, GraphQL::STRING_TYPE, required: false, - description: 'ID of a user assigned to the issues, "none" and "any" values are supported' + description: 'ID of a user assigned to the issues, "none" and "any" values are supported.' argument :created_before, Types::TimeType, required: false, - description: 'Issues created before this date' + description: 'Issues created before this date.' argument :created_after, Types::TimeType, required: false, - description: 'Issues created after this date' + description: 'Issues created after this date.' argument :updated_before, Types::TimeType, required: false, - description: 'Issues updated before this date' + description: 'Issues updated before this date.' argument :updated_after, Types::TimeType, required: false, - description: 'Issues updated after this date' + description: 'Issues updated after this date.' argument :closed_before, Types::TimeType, required: false, - description: 'Issues closed before this date' + description: 'Issues closed before this date.' argument :closed_after, Types::TimeType, required: false, - description: 'Issues closed after this date' + description: 'Issues closed after this date.' argument :search, GraphQL::STRING_TYPE, required: false, - description: 'Search query for issue title or description' + description: 'Search query for issue title or description.' argument :types, [Types::IssueTypeEnum], as: :issue_types, - description: 'Filter issues by the given issue types', + description: 'Filter issues by the given issue types.', required: false end diff --git a/app/graphql/resolvers/concerns/looks_ahead.rb b/app/graphql/resolvers/concerns/looks_ahead.rb index d468047b539..77a85edfba6 100644 --- a/app/graphql/resolvers/concerns/looks_ahead.rb +++ b/app/graphql/resolvers/concerns/looks_ahead.rb @@ -20,11 +20,11 @@ module LooksAhead includes = preloads.each.flat_map do |name, requirements| selection&.selects?(name) ? requirements : [] end - preloads = (unconditional_includes + includes).uniq + all_preloads = (unconditional_includes + includes).uniq - return query if preloads.empty? + return query if all_preloads.empty? - query.preload(*preloads) # rubocop: disable CodeReuse/ActiveRecord + query.preload(*all_preloads) # rubocop: disable CodeReuse/ActiveRecord end private diff --git a/app/graphql/resolvers/concerns/resolves_merge_requests.rb b/app/graphql/resolvers/concerns/resolves_merge_requests.rb index ab83476ddea..31444b0c592 100644 --- a/app/graphql/resolvers/concerns/resolves_merge_requests.rb +++ b/app/graphql/resolvers/concerns/resolves_merge_requests.rb @@ -40,6 +40,8 @@ module ResolvesMergeRequests def preloads { assignees: [:assignees], + reviewers: [:reviewers], + participants: MergeRequest.participant_includes, labels: [:labels], author: [:author], merged_at: [:metrics], @@ -47,6 +49,7 @@ module ResolvesMergeRequests diff_stats_summary: [:metrics], approved_by: [:approved_by_users], milestone: [:milestone], + security_auto_fix: [:author], head_pipeline: [:merge_request_diff, { head_pipeline: [:merge_request] }] } end diff --git a/app/graphql/resolvers/concerns/resolves_pipelines.rb b/app/graphql/resolvers/concerns/resolves_pipelines.rb index f061f5f1606..bbf33c0b5eb 100644 --- a/app/graphql/resolvers/concerns/resolves_pipelines.rb +++ b/app/graphql/resolvers/concerns/resolves_pipelines.rb @@ -8,15 +8,15 @@ module ResolvesPipelines argument :status, Types::Ci::PipelineStatusEnum, required: false, - description: "Filter pipelines by their status" + description: "Filter pipelines by their status." argument :ref, GraphQL::STRING_TYPE, required: false, - description: "Filter pipelines by the ref they are run for" + description: "Filter pipelines by the ref they are run for." argument :sha, GraphQL::STRING_TYPE, required: false, - description: "Filter pipelines by the sha of the commit they are run for" + description: "Filter pipelines by the sha of the commit they are run for." end class_methods do diff --git a/app/graphql/resolvers/concerns/resolves_snippets.rb b/app/graphql/resolvers/concerns/resolves_snippets.rb index 790ff4f774f..0bc38188b9a 100644 --- a/app/graphql/resolvers/concerns/resolves_snippets.rb +++ b/app/graphql/resolvers/concerns/resolves_snippets.rb @@ -8,11 +8,11 @@ module ResolvesSnippets argument :ids, [::Types::GlobalIDType[::Snippet]], required: false, - description: 'Array of global snippet ids, e.g., "gid://gitlab/ProjectSnippet/1"' + description: 'Array of global snippet ids, e.g., "gid://gitlab/ProjectSnippet/1".' argument :visibility, Types::Snippets::VisibilityScopesEnum, required: false, - description: 'The visibility of the snippet' + description: 'The visibility of the snippet.' end def resolve(**args) diff --git a/app/graphql/resolvers/concerns/time_frame_arguments.rb b/app/graphql/resolvers/concerns/time_frame_arguments.rb index 94bfe6f7f9f..6cac46a71d2 100644 --- a/app/graphql/resolvers/concerns/time_frame_arguments.rb +++ b/app/graphql/resolvers/concerns/time_frame_arguments.rb @@ -18,7 +18,7 @@ module TimeFrameArguments argument :timeframe, Types::TimeframeInputType, required: false, - description: 'List items overlapping the given timeframe' + description: 'List items overlapping the given timeframe.' end # TODO: remove when the start_date and end_date arguments are removed diff --git a/app/graphql/resolvers/container_repositories_resolver.rb b/app/graphql/resolvers/container_repositories_resolver.rb index b4b2893a3b8..8042a368e33 100644 --- a/app/graphql/resolvers/container_repositories_resolver.rb +++ b/app/graphql/resolvers/container_repositories_resolver.rb @@ -8,7 +8,7 @@ module Resolvers argument :name, GraphQL::STRING_TYPE, required: false, - description: 'Filter the container repositories by their name' + description: 'Filter the container repositories by their name.' def resolve(name: nil) ContainerRepositoriesFinder.new(user: current_user, subject: object, params: { name: name }) diff --git a/app/graphql/resolvers/design_management/design_at_version_resolver.rb b/app/graphql/resolvers/design_management/design_at_version_resolver.rb index 1b69efebe4e..533692e2b12 100644 --- a/app/graphql/resolvers/design_management/design_at_version_resolver.rb +++ b/app/graphql/resolvers/design_management/design_at_version_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::DesignManagement::DesignAtVersion], required: true, - description: 'The Global ID of the design at this version' + description: 'The Global ID of the design at this version.' def resolve(id:) authorized_find!(id: id) diff --git a/app/graphql/resolvers/design_management/design_resolver.rb b/app/graphql/resolvers/design_management/design_resolver.rb index b60c14ca835..e640f57f04a 100644 --- a/app/graphql/resolvers/design_management/design_resolver.rb +++ b/app/graphql/resolvers/design_management/design_resolver.rb @@ -9,11 +9,11 @@ module Resolvers argument :id, ::Types::GlobalIDType[::DesignManagement::Design], required: false, - description: 'Find a design by its ID' + description: 'Find a design by its ID.' argument :filename, GraphQL::STRING_TYPE, required: false, - description: 'Find a design by its filename' + description: 'Find a design by its filename.' def resolve(filename: nil, id: nil) params = parse_args(filename, id) diff --git a/app/graphql/resolvers/design_management/designs_resolver.rb b/app/graphql/resolvers/design_management/designs_resolver.rb index c588142ea6b..c45e4d01f6e 100644 --- a/app/graphql/resolvers/design_management/designs_resolver.rb +++ b/app/graphql/resolvers/design_management/designs_resolver.rb @@ -10,10 +10,10 @@ module Resolvers argument :ids, [DesignID], required: false, - description: 'Filters designs by their ID' + description: 'Filters designs by their ID.' argument :filenames, [GraphQL::STRING_TYPE], required: false, - description: 'Filters designs by their filename' + description: 'Filters designs by their filename.' argument :at_version, VersionID, required: false, description: 'Filters designs to only those that existed at the version. ' \ diff --git a/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb b/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb index 49a4974bfbf..fea74cbfb0b 100644 --- a/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb +++ b/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb @@ -19,13 +19,13 @@ module Resolvers argument :id, DesignAtVersionID, required: false, as: :design_at_version_id, - description: 'The ID of the DesignAtVersion' + description: 'The ID of the DesignAtVersion.' argument :design_id, DesignID, required: false, - description: 'The ID of a specific design' + description: 'The ID of a specific design.' argument :filename, GraphQL::STRING_TYPE, required: false, - description: 'The filename of a specific design' + description: 'The filename of a specific design.' def self.single self diff --git a/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb b/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb index a129d8620d4..930b1b60d0e 100644 --- a/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb +++ b/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb @@ -15,11 +15,11 @@ module Resolvers argument :ids, [DesignID], required: false, - description: 'Filters designs by their ID' + description: 'Filters designs by their ID.' argument :filenames, [GraphQL::STRING_TYPE], required: false, - description: 'Filters designs by their filename' + description: 'Filters designs by their filename.' def self.single ::Resolvers::DesignManagement::Version::DesignAtVersionResolver diff --git a/app/graphql/resolvers/design_management/version_in_collection_resolver.rb b/app/graphql/resolvers/design_management/version_in_collection_resolver.rb index 7d20cfc2c8e..593974beb04 100644 --- a/app/graphql/resolvers/design_management/version_in_collection_resolver.rb +++ b/app/graphql/resolvers/design_management/version_in_collection_resolver.rb @@ -17,11 +17,11 @@ module Resolvers argument :sha, GraphQL::STRING_TYPE, required: false, - description: "The SHA256 of a specific version" + description: "The SHA256 of a specific version." argument :id, VersionID, as: :version_id, required: false, - description: 'The Global ID of the version' + description: 'The Global ID of the version.' def resolve(version_id: nil, sha: nil) # TODO: remove this line when the compatibility layer is removed diff --git a/app/graphql/resolvers/design_management/version_resolver.rb b/app/graphql/resolvers/design_management/version_resolver.rb index 1bc9c1a7cd6..2144e588208 100644 --- a/app/graphql/resolvers/design_management/version_resolver.rb +++ b/app/graphql/resolvers/design_management/version_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::DesignManagement::Version], required: true, - description: 'The Global ID of the version' + description: 'The Global ID of the version.' def resolve(id:) authorized_find!(id: id) diff --git a/app/graphql/resolvers/design_management/versions_resolver.rb b/app/graphql/resolvers/design_management/versions_resolver.rb index 3c718a631db..619448cbc18 100644 --- a/app/graphql/resolvers/design_management/versions_resolver.rb +++ b/app/graphql/resolvers/design_management/versions_resolver.rb @@ -14,12 +14,12 @@ module Resolvers argument :earlier_or_equal_to_sha, GraphQL::STRING_TYPE, as: :sha, required: false, - description: 'The SHA256 of the most recent acceptable version' + description: 'The SHA256 of the most recent acceptable version.' argument :earlier_or_equal_to_id, VersionID, as: :id, required: false, - description: 'The Global ID of the most recent acceptable version' + description: 'The Global ID of the most recent acceptable version.' # This resolver has a custom singular resolver def self.single diff --git a/app/graphql/resolvers/echo_resolver.rb b/app/graphql/resolvers/echo_resolver.rb index 6b85b700712..0c7dad622cf 100644 --- a/app/graphql/resolvers/echo_resolver.rb +++ b/app/graphql/resolvers/echo_resolver.rb @@ -6,7 +6,7 @@ module Resolvers description 'Testing endpoint to validate the API with' argument :text, GraphQL::STRING_TYPE, required: true, - description: 'Text to echo back' + description: 'Text to echo back.' def resolve(text:) username = current_user&.username diff --git a/app/graphql/resolvers/environments_resolver.rb b/app/graphql/resolvers/environments_resolver.rb index 1b916a89796..ed3395d05aa 100644 --- a/app/graphql/resolvers/environments_resolver.rb +++ b/app/graphql/resolvers/environments_resolver.rb @@ -4,15 +4,15 @@ module Resolvers class EnvironmentsResolver < BaseResolver argument :name, GraphQL::STRING_TYPE, required: false, - description: 'Name of the environment' + description: 'Name of the environment.' argument :search, GraphQL::STRING_TYPE, required: false, - description: 'Search query for environment name' + description: 'Search query for environment name.' argument :states, [GraphQL::STRING_TYPE], required: false, - description: 'States of environments that should be included in result' + description: 'States of environments that should be included in result.' type Types::EnvironmentType, null: true diff --git a/app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb b/app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb index 09e76dba645..7032af46221 100644 --- a/app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb +++ b/app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb @@ -7,7 +7,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError], required: true, - description: 'ID of the Sentry issue' + description: 'ID of the Sentry issue.' def resolve(id:) # TODO: remove this line when the compatibility layer is removed diff --git a/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb b/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb index 13b5672d750..8876f8badcd 100644 --- a/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb +++ b/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb @@ -7,7 +7,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError], required: true, - description: 'ID of the Sentry issue' + description: 'ID of the Sentry issue.' def resolve(id:) # TODO: remove this line when the compatibility layer is removed diff --git a/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb b/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb index e844ffedbeb..4cd65daa655 100644 --- a/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb +++ b/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb @@ -7,12 +7,12 @@ module Resolvers extension Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension argument :search_term, ::GraphQL::STRING_TYPE, - description: 'Search query for the Sentry error details', + description: 'Search query for the Sentry error details.', required: false # TODO: convert to Enum argument :sort, ::GraphQL::STRING_TYPE, - description: 'Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default', + description: 'Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default.', required: false delegate :project, to: :object diff --git a/app/graphql/resolvers/full_path_resolver.rb b/app/graphql/resolvers/full_path_resolver.rb index cbb0bf998a6..d01cdf749a1 100644 --- a/app/graphql/resolvers/full_path_resolver.rb +++ b/app/graphql/resolvers/full_path_resolver.rb @@ -7,7 +7,7 @@ module Resolvers prepended do argument :full_path, GraphQL::ID_TYPE, required: true, - description: 'The full path of the project, group or namespace, e.g., "gitlab-org/gitlab-foss"' + description: 'The full path of the project, group or namespace, e.g., "gitlab-org/gitlab-foss".' end def model_by_full_path(model, full_path) diff --git a/app/graphql/resolvers/group_members_resolver.rb b/app/graphql/resolvers/group_members_resolver.rb index fcdf7c01d8b..36e1977b756 100644 --- a/app/graphql/resolvers/group_members_resolver.rb +++ b/app/graphql/resolvers/group_members_resolver.rb @@ -7,7 +7,7 @@ module Resolvers authorize :read_group_member argument :relations, [Types::GroupMemberRelationEnum], - description: 'Filter members by the given member relations', + description: 'Filter members by the given member relations.', required: false, default_value: GroupMembersFinder::DEFAULT_RELATIONS diff --git a/app/graphql/resolvers/group_milestones_resolver.rb b/app/graphql/resolvers/group_milestones_resolver.rb index 83b82e2720b..179283fd7b7 100644 --- a/app/graphql/resolvers/group_milestones_resolver.rb +++ b/app/graphql/resolvers/group_milestones_resolver.rb @@ -5,7 +5,7 @@ module Resolvers class GroupMilestonesResolver < MilestonesResolver argument :include_descendants, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Also return milestones in all subgroups and subprojects' + description: 'Also return milestones in all subgroups and subprojects.' type Types::MilestoneType.connection_type, null: true diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb index ae27cce9113..ac3bdda0f12 100644 --- a/app/graphql/resolvers/issues_resolver.rb +++ b/app/graphql/resolvers/issues_resolver.rb @@ -6,9 +6,9 @@ module Resolvers argument :state, Types::IssuableStateEnum, required: false, - description: 'Current state of this issue' + description: 'Current state of this issue.' argument :sort, Types::IssueSortEnum, - description: 'Sort issues by this criteria', + description: 'Sort issues by this criteria.', required: false, default_value: :created_desc @@ -19,7 +19,7 @@ module Resolvers milestone_due_asc milestone_due_desc].freeze def continue_issue_resolve(parent, finder, **args) - issues = apply_lookahead(Gitlab::Graphql::Loaders::IssuableLoader.new(parent, finder).batching_find_all) + issues = Gitlab::Graphql::Loaders::IssuableLoader.new(parent, finder).batching_find_all { |q| apply_lookahead(q) } if non_stable_cursor_sort?(args[:sort]) # Certain complex sorts are not supported by the stable cursor pagination yet. @@ -32,6 +32,14 @@ module Resolvers private + def unconditional_includes + [ + { + project: [:project_feature] + } + ] + end + def preloads { alert_management_alert: [:alert_management_alert], diff --git a/app/graphql/resolvers/members_resolver.rb b/app/graphql/resolvers/members_resolver.rb index cf51fd298bd..76c3ae936ee 100644 --- a/app/graphql/resolvers/members_resolver.rb +++ b/app/graphql/resolvers/members_resolver.rb @@ -9,7 +9,7 @@ module Resolvers argument :search, GraphQL::STRING_TYPE, required: false, - description: 'Search query' + description: 'Search query.' def resolve_with_lookahead(**args) authorize!(object) diff --git a/app/graphql/resolvers/merge_request_resolver.rb b/app/graphql/resolvers/merge_request_resolver.rb index 4cad65fa697..8fd33c6626e 100644 --- a/app/graphql/resolvers/merge_request_resolver.rb +++ b/app/graphql/resolvers/merge_request_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :iid, GraphQL::STRING_TYPE, required: true, as: :iids, - description: 'IID of the merge request, for example `1`' + description: 'IID of the merge request, for example `1`.' def no_results_possible?(args) project.nil? diff --git a/app/graphql/resolvers/merge_requests_resolver.rb b/app/graphql/resolvers/merge_requests_resolver.rb index 98c95565778..ecbdaaa3f55 100644 --- a/app/graphql/resolvers/merge_requests_resolver.rb +++ b/app/graphql/resolvers/merge_requests_resolver.rb @@ -11,24 +11,24 @@ module Resolvers def self.accept_assignee argument :assignee_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of the assignee' + description: 'Username of the assignee.' end def self.accept_author argument :author_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of the author' + description: 'Username of the author.' end def self.accept_reviewer argument :reviewer_username, GraphQL::STRING_TYPE, required: false, - description: 'Username of the reviewer' + description: 'Username of the reviewer.' end argument :iids, [GraphQL::STRING_TYPE], required: false, - description: 'Array of IIDs of merge requests, for example `[1, 2]`' + description: 'Array of IIDs of merge requests, for example `[1, 2]`.' argument :source_branches, [GraphQL::STRING_TYPE], required: false, @@ -50,15 +50,15 @@ module Resolvers description: 'Array of label names. All resolved merge requests will have all of these labels.' argument :merged_after, Types::TimeType, required: false, - description: 'Merge requests merged after this date' + description: 'Merge requests merged after this date.' argument :merged_before, Types::TimeType, required: false, - description: 'Merge requests merged before this date' + description: 'Merge requests merged before this date.' argument :milestone_title, GraphQL::STRING_TYPE, required: false, - description: 'Title of the milestone' + description: 'Title of the milestone.' argument :sort, Types::MergeRequestSortEnum, - description: 'Sort merge requests by this criteria', + description: 'Sort merge requests by this criteria.', required: false, default_value: :created_desc diff --git a/app/graphql/resolvers/metrics/dashboard_resolver.rb b/app/graphql/resolvers/metrics/dashboard_resolver.rb index 18a654c7dc5..f569cb0b2c3 100644 --- a/app/graphql/resolvers/metrics/dashboard_resolver.rb +++ b/app/graphql/resolvers/metrics/dashboard_resolver.rb @@ -5,7 +5,7 @@ module Resolvers class DashboardResolver < Resolvers::BaseResolver argument :path, GraphQL::STRING_TYPE, required: true, - description: "Path to a file which defines metrics dashboard eg: 'config/prometheus/common_metrics.yml'" + description: "Path to a file which defines metrics dashboard eg: 'config/prometheus/common_metrics.yml'." type Types::Metrics::DashboardType, null: true diff --git a/app/graphql/resolvers/metrics/dashboards/annotation_resolver.rb b/app/graphql/resolvers/metrics/dashboards/annotation_resolver.rb index 2dd224bb17b..9d6b0486c04 100644 --- a/app/graphql/resolvers/metrics/dashboards/annotation_resolver.rb +++ b/app/graphql/resolvers/metrics/dashboards/annotation_resolver.rb @@ -6,11 +6,11 @@ module Resolvers class AnnotationResolver < Resolvers::BaseResolver argument :from, Types::TimeType, required: true, - description: "Timestamp marking date and time from which annotations need to be fetched" + description: "Timestamp marking date and time from which annotations need to be fetched." argument :to, Types::TimeType, required: false, - description: "Timestamp marking date and time to which annotations need to be fetched" + description: "Timestamp marking date and time to which annotations need to be fetched." type Types::Metrics::Dashboards::AnnotationType, null: true diff --git a/app/graphql/resolvers/milestones_resolver.rb b/app/graphql/resolvers/milestones_resolver.rb index 564e388d571..9a715e4d08b 100644 --- a/app/graphql/resolvers/milestones_resolver.rb +++ b/app/graphql/resolvers/milestones_resolver.rb @@ -7,23 +7,23 @@ module Resolvers argument :ids, [GraphQL::ID_TYPE], required: false, - description: 'Array of global milestone IDs, e.g., "gid://gitlab/Milestone/1"' + description: 'Array of global milestone IDs, e.g., "gid://gitlab/Milestone/1".' argument :state, Types::MilestoneStateEnum, required: false, - description: 'Filter milestones by state' + description: 'Filter milestones by state.' argument :title, GraphQL::STRING_TYPE, required: false, - description: 'The title of the milestone' + description: 'The title of the milestone.' argument :search_title, GraphQL::STRING_TYPE, required: false, - description: 'A search string for the title' + description: 'A search string for the title.' argument :containing_date, Types::TimeType, required: false, - description: 'A date that the milestone contains' + description: 'A date that the milestone contains.' type Types::MilestoneType.connection_type, null: true diff --git a/app/graphql/resolvers/namespace_projects_resolver.rb b/app/graphql/resolvers/namespace_projects_resolver.rb index 9f57c8f3405..da44b9b5623 100644 --- a/app/graphql/resolvers/namespace_projects_resolver.rb +++ b/app/graphql/resolvers/namespace_projects_resolver.rb @@ -5,17 +5,17 @@ module Resolvers argument :include_subgroups, GraphQL::BOOLEAN_TYPE, required: false, default_value: false, - description: 'Include also subgroup projects' + description: 'Include also subgroup projects.' argument :search, GraphQL::STRING_TYPE, required: false, default_value: nil, - description: 'Search project with most similar names or paths' + description: 'Search project with most similar names or paths.' argument :sort, Types::Projects::NamespaceProjectSortEnum, required: false, default_value: nil, - description: 'Sort projects by this criteria' + description: 'Sort projects by this criteria.' type Types::ProjectType, null: true diff --git a/app/graphql/resolvers/package_details_resolver.rb b/app/graphql/resolvers/package_details_resolver.rb new file mode 100644 index 00000000000..dcf4430e55f --- /dev/null +++ b/app/graphql/resolvers/package_details_resolver.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Resolvers + # No return types defined because they can be different. + # rubocop: disable Graphql/ResolverType + class PackageDetailsResolver < BaseResolver + argument :id, ::Types::GlobalIDType[::Packages::Package], + required: true, + description: 'The global ID of the package.' + + def resolve(id:) + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id = ::Types::GlobalIDType[::Packages::Package].coerce_isolated_input(id) + GitlabSchema.find_by_gid(id) + end + end +end diff --git a/app/graphql/resolvers/packages_resolver.rb b/app/graphql/resolvers/packages_resolver.rb index 519fb87183e..d19099e94d4 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::PackageType, null: true + type Types::Packages::PackageType, null: true def resolve(**args) return unless packages_available? diff --git a/app/graphql/resolvers/project_members_resolver.rb b/app/graphql/resolvers/project_members_resolver.rb index 659b12c2563..e889b47c000 100644 --- a/app/graphql/resolvers/project_members_resolver.rb +++ b/app/graphql/resolvers/project_members_resolver.rb @@ -6,7 +6,7 @@ module Resolvers authorize :read_project_member argument :relations, [Types::ProjectMemberRelationEnum], - description: 'Filter members by the given member relations', + description: 'Filter members by the given member relations.', required: false, default_value: MembersFinder::DEFAULT_RELATIONS diff --git a/app/graphql/resolvers/project_milestones_resolver.rb b/app/graphql/resolvers/project_milestones_resolver.rb index c88c9ce7219..4cd9cb53f56 100644 --- a/app/graphql/resolvers/project_milestones_resolver.rb +++ b/app/graphql/resolvers/project_milestones_resolver.rb @@ -5,7 +5,7 @@ module Resolvers class ProjectMilestonesResolver < MilestonesResolver argument :include_ancestors, GraphQL::BOOLEAN_TYPE, required: false, - description: "Also return milestones in the project's parent group and its ancestors" + description: "Also return milestones in the project's parent group and its ancestors." type Types::MilestoneType.connection_type, null: true diff --git a/app/graphql/resolvers/project_pipeline_resolver.rb b/app/graphql/resolvers/project_pipeline_resolver.rb index 8bf4e0b08ef..b604a408928 100644 --- a/app/graphql/resolvers/project_pipeline_resolver.rb +++ b/app/graphql/resolvers/project_pipeline_resolver.rb @@ -8,7 +8,7 @@ module Resolvers argument :iid, GraphQL::ID_TYPE, required: true, - description: 'IID of the Pipeline, e.g., "1"' + description: 'IID of the Pipeline, e.g., "1".' def resolve(iid:) BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader, args| diff --git a/app/graphql/resolvers/projects/jira_projects_resolver.rb b/app/graphql/resolvers/projects/jira_projects_resolver.rb index 31f42d305b0..de85e8c42e6 100644 --- a/app/graphql/resolvers/projects/jira_projects_resolver.rb +++ b/app/graphql/resolvers/projects/jira_projects_resolver.rb @@ -6,11 +6,12 @@ module Resolvers include Gitlab::Graphql::Authorize::AuthorizeResource type Types::Projects::Services::JiraProjectType.connection_type, null: true + authorize :admin_project argument :name, GraphQL::STRING_TYPE, required: false, - description: 'Project name or key' + description: 'Project name or key.' def resolve(name: nil, **args) authorize!(project) @@ -31,10 +32,6 @@ module Resolvers end end - def authorized_resource?(project) - Ability.allowed?(context[:current_user], :admin_project, project) - end - private alias_method :jira_service, :object diff --git a/app/graphql/resolvers/projects/services_resolver.rb b/app/graphql/resolvers/projects/services_resolver.rb index 4f5a6cddbb3..f618bf2df77 100644 --- a/app/graphql/resolvers/projects/services_resolver.rb +++ b/app/graphql/resolvers/projects/services_resolver.rb @@ -12,11 +12,11 @@ module Resolvers argument :active, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Indicates if the service is active' + description: 'Indicates if the service is active.' argument :type, Types::Projects::ServiceTypeEnum, required: false, - description: 'Class name of the service' + description: 'Class name of the service.' alias_method :project, :object diff --git a/app/graphql/resolvers/projects_resolver.rb b/app/graphql/resolvers/projects_resolver.rb index 69438229a50..11d18a0a080 100644 --- a/app/graphql/resolvers/projects_resolver.rb +++ b/app/graphql/resolvers/projects_resolver.rb @@ -6,23 +6,23 @@ module Resolvers argument :membership, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Limit projects that the current user is a member of' + description: 'Limit projects that the current user is a member of.' argument :search, GraphQL::STRING_TYPE, required: false, - description: 'Search query for project name, path, or description' + description: 'Search query for project name, path, or description.' argument :ids, [GraphQL::ID_TYPE], required: false, - description: 'Filter projects by IDs' + description: 'Filter projects by IDs.' argument :search_namespaces, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Include namespace in project search' + description: 'Include namespace in project search.' argument :sort, GraphQL::STRING_TYPE, required: false, - description: 'Sort order of results' + description: 'Sort order of results.' def resolve(**args) ProjectsFinder diff --git a/app/graphql/resolvers/release_milestones_resolver.rb b/app/graphql/resolvers/release_milestones_resolver.rb new file mode 100644 index 00000000000..7582c91272f --- /dev/null +++ b/app/graphql/resolvers/release_milestones_resolver.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Resolvers + class ReleaseMilestonesResolver < BaseResolver + type Types::MilestoneType.connection_type, null: true + + alias_method :release, :object + + def resolve(**args) + offset_pagination(release.milestones.order_by_dates_and_title) + end + end +end diff --git a/app/graphql/resolvers/release_resolver.rb b/app/graphql/resolvers/release_resolver.rb index 1edcc8c70b5..20ef01f8593 100644 --- a/app/graphql/resolvers/release_resolver.rb +++ b/app/graphql/resolvers/release_resolver.rb @@ -6,7 +6,7 @@ module Resolvers argument :tag_name, GraphQL::STRING_TYPE, required: true, - description: 'The name of the tag associated to the release' + description: 'The name of the tag associated to the release.' alias_method :project, :object diff --git a/app/graphql/resolvers/releases_resolver.rb b/app/graphql/resolvers/releases_resolver.rb index 8e8127cf279..01c1e9b11e7 100644 --- a/app/graphql/resolvers/releases_resolver.rb +++ b/app/graphql/resolvers/releases_resolver.rb @@ -6,7 +6,7 @@ module Resolvers argument :sort, Types::ReleaseSortEnum, required: false, default_value: :released_at_desc, - description: 'Sort releases by this criteria' + description: 'Sort releases by this criteria.' alias_method :project, :object diff --git a/app/graphql/resolvers/snippets/blobs_resolver.rb b/app/graphql/resolvers/snippets/blobs_resolver.rb index cfb1711aed4..868d34ae7ad 100644 --- a/app/graphql/resolvers/snippets/blobs_resolver.rb +++ b/app/graphql/resolvers/snippets/blobs_resolver.rb @@ -13,7 +13,7 @@ module Resolvers argument :paths, [GraphQL::STRING_TYPE], required: false, - description: 'Paths of the blobs' + description: 'Paths of the blobs.' def resolve(**args) authorize!(snippet) diff --git a/app/graphql/resolvers/snippets_resolver.rb b/app/graphql/resolvers/snippets_resolver.rb index 77099565df0..7153c919062 100644 --- a/app/graphql/resolvers/snippets_resolver.rb +++ b/app/graphql/resolvers/snippets_resolver.rb @@ -11,20 +11,20 @@ module Resolvers argument :author_id, ::Types::GlobalIDType[::User], required: false, - description: 'The ID of an author' + description: 'The ID of an author.' argument :project_id, ::Types::GlobalIDType[::Project], required: false, - description: 'The ID of a project' + description: 'The ID of a project.' argument :type, Types::Snippets::TypeEnum, required: false, - description: 'The type of snippet' + description: 'The type of snippet.' argument :explore, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Explore personal snippets' + description: 'Explore personal snippets.' def resolve(**args) if args[:author_id].present? && args[:project_id].present? diff --git a/app/graphql/resolvers/todo_resolver.rb b/app/graphql/resolvers/todo_resolver.rb index 9a8f7a71154..8966285fccc 100644 --- a/app/graphql/resolvers/todo_resolver.rb +++ b/app/graphql/resolvers/todo_resolver.rb @@ -8,27 +8,27 @@ module Resolvers argument :action, [Types::TodoActionEnum], required: false, - description: 'The action to be filtered' + description: 'The action to be filtered.' argument :author_id, [GraphQL::ID_TYPE], required: false, - description: 'The ID of an author' + description: 'The ID of an author.' argument :project_id, [GraphQL::ID_TYPE], required: false, - description: 'The ID of a project' + description: 'The ID of a project.' argument :group_id, [GraphQL::ID_TYPE], required: false, - description: 'The ID of a group' + description: 'The ID of a group.' argument :state, [Types::TodoStateEnum], required: false, - description: 'The state of the todo' + description: 'The state of the todo.' argument :type, [Types::TodoTargetEnum], required: false, - description: 'The type of the todo' + description: 'The type of the todo.' def resolve(**args) return Todo.none unless current_user.present? && target.present? diff --git a/app/graphql/resolvers/tree_resolver.rb b/app/graphql/resolvers/tree_resolver.rb index 075a1929c47..7a70c35897d 100644 --- a/app/graphql/resolvers/tree_resolver.rb +++ b/app/graphql/resolvers/tree_resolver.rb @@ -7,15 +7,15 @@ module Resolvers argument :path, GraphQL::STRING_TYPE, required: false, default_value: '', - description: 'The path to get the tree for. Default value is the root of the repository' + description: 'The path to get the tree for. Default value is the root of the repository.' argument :ref, GraphQL::STRING_TYPE, required: false, default_value: :head, - description: 'The commit ref to get the tree for. Default value is HEAD' + description: 'The commit ref to get the tree for. Default value is HEAD.' argument :recursive, GraphQL::BOOLEAN_TYPE, required: false, default_value: false, - description: 'Used to get a recursive tree. Default is false' + description: 'Used to get a recursive tree. Default is false.' alias_method :repository, :object diff --git a/app/graphql/resolvers/user_resolver.rb b/app/graphql/resolvers/user_resolver.rb index 06c1f0cb42d..84bc03091d9 100644 --- a/app/graphql/resolvers/user_resolver.rb +++ b/app/graphql/resolvers/user_resolver.rb @@ -8,11 +8,11 @@ module Resolvers argument :id, Types::GlobalIDType[User], required: false, - description: 'ID of the User' + description: 'ID of the User.' argument :username, GraphQL::STRING_TYPE, required: false, - description: 'Username of the User' + description: 'Username of the User.' def ready?(id: nil, username: nil) unless id.present? ^ username.present? diff --git a/app/graphql/resolvers/user_starred_projects_resolver.rb b/app/graphql/resolvers/user_starred_projects_resolver.rb index cc3bb90decf..db420b3d116 100644 --- a/app/graphql/resolvers/user_starred_projects_resolver.rb +++ b/app/graphql/resolvers/user_starred_projects_resolver.rb @@ -6,7 +6,7 @@ module Resolvers argument :search, GraphQL::STRING_TYPE, required: false, - description: 'Search query' + description: 'Search query.' alias_method :user, :object diff --git a/app/graphql/resolvers/users/snippets_resolver.rb b/app/graphql/resolvers/users/snippets_resolver.rb index c2d42437ffd..e8048b9deb9 100644 --- a/app/graphql/resolvers/users/snippets_resolver.rb +++ b/app/graphql/resolvers/users/snippets_resolver.rb @@ -10,7 +10,7 @@ module Resolvers argument :type, Types::Snippets::TypeEnum, required: false, - description: 'The type of snippet' + description: 'The type of snippet.' private diff --git a/app/graphql/resolvers/users_resolver.rb b/app/graphql/resolvers/users_resolver.rb index a0ed076595d..95ced131504 100644 --- a/app/graphql/resolvers/users_resolver.rb +++ b/app/graphql/resolvers/users_resolver.rb @@ -9,13 +9,13 @@ module Resolvers argument :ids, [GraphQL::ID_TYPE], required: false, - description: 'List of user Global IDs' + description: 'List of user Global IDs.' argument :usernames, [GraphQL::STRING_TYPE], required: false, - description: 'List of usernames' + description: 'List of usernames.' argument :sort, Types::SortEnum, - description: 'Sort users by this criteria', + description: 'Sort users by this criteria.', required: false, default_value: :created_desc @@ -23,10 +23,15 @@ module Resolvers required: false, description: "Query to search users by name, username, or primary email." - def resolve(ids: nil, usernames: nil, sort: nil, search: nil) + argument :admins, GraphQL::BOOLEAN_TYPE, + required: false, + default_value: false, + description: 'Return only admin users.' + + def resolve(ids: nil, usernames: nil, sort: nil, search: nil, admins: nil) authorize! - ::UsersFinder.new(context[:current_user], finder_params(ids, usernames, sort, search)).execute + ::UsersFinder.new(context[:current_user], finder_params(ids, usernames, sort, search, admins)).execute end def ready?(**args) @@ -34,7 +39,7 @@ module Resolvers return super if args.values.compact.blank? - if args.values.all? + if args[:usernames]&.present? && args[:ids]&.present? raise Gitlab::Graphql::Errors::ArgumentError, 'Provide either a list of usernames or ids' end @@ -47,12 +52,13 @@ module Resolvers private - def finder_params(ids, usernames, sort, search) + def finder_params(ids, usernames, sort, search, admins) params = {} params[:sort] = sort if sort params[:username] = usernames if usernames params[:id] = parse_gids(ids) if ids params[:search] = search if search + params[:admins] = admins if admins params end |