Commit 95ac4322 authored by Alex Kalderimis's avatar Alex Kalderimis

Rubocop: Fix todo-ed violations

This fixes a number of TODO-ed Rubocop violations.
parent b49f92b4
...@@ -29,12 +29,10 @@ module Mutations ...@@ -29,12 +29,10 @@ module Mutations
end end
def ready?(**args) def ready?(**args)
if Gitlab::Database.read_only? raise_resource_not_available_error! ERROR_MESSAGE if Gitlab::Database.read_only?
raise_resource_not_available_error! ERROR_MESSAGE
else
true true
end end
end
def load_application_object(argument, lookup_as_type, id, context) def load_application_object(argument, lookup_as_type, id, context)
::Gitlab::Graphql::Lazy.new { super }.catch(::GraphQL::UnauthorizedError) do |e| ::Gitlab::Graphql::Lazy.new { super }.catch(::GraphQL::UnauthorizedError) do |e|
......
...@@ -7,6 +7,10 @@ module Resolvers ...@@ -7,6 +7,10 @@ module Resolvers
include ResolvesProject include ResolvesProject
type Types::Ci::Config::ConfigType, null: true type Types::Ci::Config::ConfigType, null: true
description <<~MD
Linted and processed contents of a CI config.
Should not be requested more than once per request.
MD
authorize :read_pipeline authorize :read_pipeline
...@@ -55,7 +59,7 @@ module Resolvers ...@@ -55,7 +59,7 @@ module Resolvers
name: job[:name], name: job[:name],
stage: job[:stage], stage: job[:stage],
group_name: CommitStatus.new(name: job[:name]).group_name, group_name: CommitStatus.new(name: job[:name]).group_name,
needs: job.dig(:needs) || [], needs: job[:needs] || [],
allow_failure: job[:allow_failure], allow_failure: job[:allow_failure],
before_script: job[:before_script], before_script: job[:before_script],
script: job[:script], script: job[:script],
......
...@@ -3,22 +3,28 @@ ...@@ -3,22 +3,28 @@
module Resolvers module Resolvers
module Ci module Ci
class RunnerSetupResolver < BaseResolver class RunnerSetupResolver < BaseResolver
ACCESS_DENIED = 'User is not authorized to register a runner for the specified resource!'
type Types::Ci::RunnerSetupType, null: true type Types::Ci::RunnerSetupType, null: true
description 'Runner setup instructions.' description 'Runner setup instructions.'
argument :platform, GraphQL::STRING_TYPE, argument :platform,
type: GraphQL::STRING_TYPE,
required: true, required: true,
description: 'Platform to generate the instructions for.' description: 'Platform to generate the instructions for.'
argument :architecture, GraphQL::STRING_TYPE, argument :architecture,
type: GraphQL::STRING_TYPE,
required: true, required: true,
description: 'Architecture to generate the instructions for.' description: 'Architecture to generate the instructions for.'
argument :project_id, ::Types::GlobalIDType[::Project], argument :project_id,
type: ::Types::GlobalIDType[::Project],
required: false, required: false,
description: 'Project to register the runner for.' description: 'Project to register the runner for.'
argument :group_id, ::Types::GlobalIDType[::Group], argument :group_id,
type: ::Types::GlobalIDType[::Group],
required: false, required: false,
description: 'Group to register the runner for.' description: 'Group to register the runner for.'
...@@ -35,11 +41,15 @@ module Resolvers ...@@ -35,11 +41,15 @@ module Resolvers
register_instructions: instructions.register_command register_instructions: instructions.register_command
} }
ensure ensure
raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'User is not authorized to register a runner for the specified resource!' if instructions.errors.include?('Gitlab::Access::AccessDeniedError') raise Gitlab::Graphql::Errors::ResourceNotAvailable, ACCESS_DENIED if access_denied?(instructions)
end end
private private
def access_denied?(instructions)
instructions.errors.include?('Gitlab::Access::AccessDeniedError')
end
def other_install_instructions(platform) def other_install_instructions(platform)
Gitlab::Ci::RunnerInstructions::OTHER_ENVIRONMENTS[platform.to_sym][:installation_instructions_url] Gitlab::Ci::RunnerInstructions::OTHER_ENVIRONMENTS[platform.to_sym][:installation_instructions_url]
end end
......
...@@ -5,7 +5,9 @@ module Resolvers ...@@ -5,7 +5,9 @@ module Resolvers
type ::GraphQL::STRING_TYPE, null: false type ::GraphQL::STRING_TYPE, null: false
description 'Testing endpoint to validate the API with' description 'Testing endpoint to validate the API with'
argument :text, GraphQL::STRING_TYPE, required: true, argument :text,
type: GraphQL::STRING_TYPE,
required: true,
description: 'Text to echo back.' description: 'Text to echo back.'
def resolve(text:) def resolve(text:)
......
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Graphql/ResolverType (inherited from MilestonesResolver)
module Resolvers module Resolvers
class GroupMilestonesResolver < MilestonesResolver class GroupMilestonesResolver < MilestonesResolver
......
...@@ -10,7 +10,10 @@ module Types ...@@ -10,7 +10,10 @@ module Types
argument :not, NegatedBoardIssueInputType, argument :not, NegatedBoardIssueInputType,
required: false, required: false,
description: 'List of negated params. Warning: this argument is experimental and a subject to change in future.' description: <<~MD
List of negated arguments.
Warning: this argument is experimental and a subject to change in future.
MD
argument :search, GraphQL::STRING_TYPE, argument :search, GraphQL::STRING_TYPE,
required: false, required: false,
......
...@@ -8,39 +8,65 @@ module Types ...@@ -8,39 +8,65 @@ module Types
expose_permissions Types::PermissionTypes::Group expose_permissions Types::PermissionTypes::Group
field :web_url, GraphQL::STRING_TYPE, null: false, field :web_url,
type: 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, field :avatar_url,
type: 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, field :custom_emoji,
type: Types::CustomEmojiType.connection_type,
null: true,
description: 'Custom emoji within this namespace.', description: 'Custom emoji within this namespace.',
feature_flag: :custom_emoji feature_flag: :custom_emoji
field :share_with_group_lock, GraphQL::BOOLEAN_TYPE, null: true, field :share_with_group_lock,
type: 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, field :project_creation_level,
type: 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, field :subgroup_creation_level,
type: 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, field :require_two_factor_authentication,
type: 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, field :two_factor_grace_period,
type: 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, field :auto_devops_enabled,
type: 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, field :emails_disabled,
type: 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, field :mentions_disabled,
type: 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, field :parent,
type: GroupType,
null: true,
description: 'Parent group.' description: 'Parent group.'
field :issues, field :issues,
...@@ -55,7 +81,7 @@ module Types ...@@ -55,7 +81,7 @@ module Types
description: 'Merge requests for projects in this group.', description: 'Merge requests for projects in this group.',
resolver: Resolvers::GroupMergeRequestsResolver resolver: Resolvers::GroupMergeRequestsResolver
field :milestones, Types::MilestoneType.connection_type, null: true, field :milestones,
description: 'Milestones of the group.', description: 'Milestones of the group.',
resolver: Resolvers::GroupMilestonesResolver resolver: Resolvers::GroupMilestonesResolver
...@@ -76,7 +102,8 @@ module Types ...@@ -76,7 +102,8 @@ module Types
Types::LabelType, Types::LabelType,
null: true, null: true,
description: 'A label available on this group.' do description: 'A label available on this group.' do
argument :title, GraphQL::STRING_TYPE, argument :title,
type: GraphQL::STRING_TYPE,
required: true, required: true,
description: 'Title of the label.' description: 'Title of the label.'
end end
...@@ -92,7 +119,9 @@ module Types ...@@ -92,7 +119,9 @@ module Types
resolver: Resolvers::ContainerRepositoriesResolver, resolver: Resolvers::ContainerRepositoriesResolver,
authorize: :read_container_image authorize: :read_container_image
field :container_repositories_count, GraphQL::INT_TYPE, null: false, field :container_repositories_count,
type: GraphQL::INT_TYPE,
null: false,
description: 'Number of container repositories in the group.' description: 'Number of container repositories in the group.'
field :packages, field :packages,
......
...@@ -11,6 +11,6 @@ module Types ...@@ -11,6 +11,6 @@ module Types
argument :gitlab_id, argument :gitlab_id,
GraphQL::INT_TYPE, GraphQL::INT_TYPE,
required: false, required: false,
description: 'Id of the GitLab user.' description: 'ID of the GitLab user.'
end end
end end
...@@ -55,7 +55,10 @@ module Types ...@@ -55,7 +55,10 @@ module Types
field :container_repository, Types::ContainerRepositoryDetailsType, field :container_repository, Types::ContainerRepositoryDetailsType,
null: true, null: true,
description: 'Find a container repository.' do description: 'Find a container repository.' do
argument :id, ::Types::GlobalIDType[::ContainerRepository], required: true, description: 'The global ID of the container repository.' argument :id,
type: ::Types::GlobalIDType[::ContainerRepository],
required: true,
description: 'The global ID of the container repository.'
end end
field :package, field :package,
...@@ -72,9 +75,7 @@ module Types ...@@ -72,9 +75,7 @@ module Types
description: 'Find users.', description: 'Find users.',
resolver: Resolvers::UsersResolver resolver: Resolvers::UsersResolver
field :echo, GraphQL::STRING_TYPE, null: false, field :echo, resolver: Resolvers::EchoResolver
description: 'Text to echo back.',
resolver: Resolvers::EchoResolver
field :issue, Types::IssueType, field :issue, Types::IssueType,
null: true, null: true,
...@@ -102,18 +103,10 @@ module Types ...@@ -102,18 +103,10 @@ module Types
null: true, null: true,
description: 'CI related settings that apply to the entire instance.' description: 'CI related settings that apply to the entire instance.'
field :runner_platforms, Types::Ci::RunnerPlatformType.connection_type, field :runner_platforms, resolver: Resolvers::Ci::RunnerPlatformsResolver
null: true, description: 'Supported runner platforms.', field :runner_setup, resolver: Resolvers::Ci::RunnerSetupResolver
resolver: Resolvers::Ci::RunnerPlatformsResolver
field :runner_setup, Types::Ci::RunnerSetupType, null: true, field :ci_config, resolver: Resolvers::Ci::ConfigResolver, complexity: 126 # AUTHENTICATED_COMPLEXITY / 2 + 1
description: 'Get runner setup instructions.',
resolver: Resolvers::Ci::RunnerSetupResolver
field :ci_config, Types::Ci::Config::ConfigType, null: true,
description: 'Get linted and processed contents of a CI config. Should not be requested more than once per request.',
resolver: Resolvers::Ci::ConfigResolver,
complexity: 126 # AUTHENTICATED_COMPLEXITY / 2 + 1
def design_management def design_management
DesignManagementObject.new(nil) DesignManagementObject.new(nil)
......
...@@ -11,44 +11,72 @@ module Types ...@@ -11,44 +11,72 @@ module Types
expose_permissions Types::PermissionTypes::User expose_permissions Types::PermissionTypes::User
field :id, GraphQL::ID_TYPE, null: false, field :id,
type: GraphQL::ID_TYPE,
null: false,
description: 'ID of the user.' description: 'ID of the user.'
field :bot, GraphQL::BOOLEAN_TYPE, null: false, field :bot,
type: GraphQL::BOOLEAN_TYPE,
null: false,
description: 'Indicates if the user is a bot.', description: 'Indicates if the user is a bot.',
method: :bot? method: :bot?
field :username, GraphQL::STRING_TYPE, null: false, field :username,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Username of the user. Unique within this instance of GitLab.' description: 'Username of the user. Unique within this instance of GitLab.'
field :name, GraphQL::STRING_TYPE, null: false, field :name,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Human-readable name of the user.' description: 'Human-readable name of the user.'
field :state, Types::UserStateEnum, null: false, field :state,
type: Types::UserStateEnum,
null: false,
description: 'State of the user.' description: 'State of the user.'
field :email, GraphQL::STRING_TYPE, null: true, field :email,
type: GraphQL::STRING_TYPE,
null: true,
description: 'User email.', method: :public_email, description: 'User email.', method: :public_email,
deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' } deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' }
field :public_email, GraphQL::STRING_TYPE, null: true, field :public_email,
type: GraphQL::STRING_TYPE,
null: true,
description: "User's public email." description: "User's public email."
field :avatar_url, GraphQL::STRING_TYPE, null: true, field :avatar_url,
type: GraphQL::STRING_TYPE,
null: true,
description: "URL of the user's avatar." description: "URL of the user's avatar."
field :web_url, GraphQL::STRING_TYPE, null: false, field :web_url,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Web URL of the user.' description: 'Web URL of the user.'
field :web_path, GraphQL::STRING_TYPE, null: false, field :web_path,
type: GraphQL::STRING_TYPE,
null: false,
description: 'Web path of the user.' description: 'Web path of the user.'
field :todos, Types::TodoType.connection_type, null: false, field :todos,
resolver: Resolvers::TodoResolver, resolver: Resolvers::TodoResolver,
description: 'To-do items of the user.' description: 'To-do items of the user.'
field :group_memberships, Types::GroupMemberType.connection_type, null: true, field :group_memberships,
type: Types::GroupMemberType.connection_type,
null: true,
description: 'Group memberships of the user.' description: 'Group memberships of the user.'
field :group_count, GraphQL::INT_TYPE, null: true, field :group_count,
resolver: Resolvers::Users::GroupCountResolver, resolver: Resolvers::Users::GroupCountResolver,
description: 'Group count for the user.', description: 'Group count for the user.',
feature_flag: :user_group_counts feature_flag: :user_group_counts
field :status, Types::UserStatusType, null: true, field :status,
type: Types::UserStatusType,
null: true,
description: 'User status.' description: 'User status.'
field :location, ::GraphQL::STRING_TYPE, null: true, field :location,
type: ::GraphQL::STRING_TYPE,
null: true,
description: 'The location of the user.' description: 'The location of the user.'
field :project_memberships, Types::ProjectMemberType.connection_type, null: true, field :project_memberships,
type: Types::ProjectMemberType.connection_type,
null: true,
description: 'Project memberships of the user.' description: 'Project memberships of the user.'
field :starred_projects, Types::ProjectType.connection_type, null: true, field :starred_projects,
description: 'Projects starred by the user.', description: 'Projects starred by the user.',
resolver: Resolvers::UserStarredProjectsResolver resolver: Resolvers::UserStarredProjectsResolver
...@@ -64,8 +92,6 @@ module Types ...@@ -64,8 +92,6 @@ module Types
description: 'Merge Requests assigned to the user for review.' description: 'Merge Requests assigned to the user for review.'
field :snippets, field :snippets,
Types::SnippetType.connection_type,
null: true,
description: 'Snippets authored by the user.', description: 'Snippets authored by the user.',
resolver: Resolvers::Users::SnippetsResolver resolver: Resolvers::Users::SnippetsResolver
field :callouts, field :callouts,
......
...@@ -32,15 +32,20 @@ module EE ...@@ -32,15 +32,20 @@ module EE
field :vulnerabilities_count_by_day, field :vulnerabilities_count_by_day,
::Types::VulnerabilitiesCountByDayType.connection_type, ::Types::VulnerabilitiesCountByDayType.connection_type,
null: true, null: true,
description: "Number of vulnerabilities per day for the projects on the current user's instance security dashboard.", resolver: ::Resolvers::VulnerabilitiesCountPerDayResolver,
resolver: ::Resolvers::VulnerabilitiesCountPerDayResolver description: <<~DESC
Number of vulnerabilities per day for the projects on the current user's instance security dashboard.
DESC
field :vulnerabilities_count_by_day_and_severity, field :vulnerabilities_count_by_day_and_severity,
::Types::VulnerabilitiesCountByDayAndSeverityType.connection_type, ::Types::VulnerabilitiesCountByDayAndSeverityType.connection_type,
null: true, null: true,
description: "Number of vulnerabilities per severity level, per day, for the projects on the current user's instance security dashboard.",
resolver: ::Resolvers::VulnerabilitiesHistoryResolver, resolver: ::Resolvers::VulnerabilitiesHistoryResolver,
deprecated: { reason: :discouraged, replacement: 'Query.vulnerabilitiesCountByDay', milestone: '13.3' } deprecated: { reason: :discouraged, replacement: 'Query.vulnerabilitiesCountByDay', milestone: '13.3' },
description: <<~DESC
Number of vulnerabilities per severity level, per day, for the projects on the
current user's instance security dashboard.
DESC
field :geo_node, ::Types::Geo::GeoNodeType, field :geo_node, ::Types::Geo::GeoNodeType,
null: true, null: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment