Commit cb6042bd authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'cop-for-graphql-field-descriptions-ee' into 'master'

Add cop to check for GraphQL field descriptions (EE)

See merge request gitlab-org/gitlab-ee!16438
parents a4e3f81f 0f1936d6
...@@ -275,8 +275,15 @@ RSpec/BeSuccessMatcher: ...@@ -275,8 +275,15 @@ RSpec/BeSuccessMatcher:
- 'ee/spec/support/shared_examples/controllers/**/*' - 'ee/spec/support/shared_examples/controllers/**/*'
- 'spec/support/controllers/**/*' - 'spec/support/controllers/**/*'
- 'ee/spec/support/controllers/**/*' - 'ee/spec/support/controllers/**/*'
Scalability/FileUploads: Scalability/FileUploads:
Enabled: true Enabled: true
Include: Include:
- 'lib/api/**/*.rb' - 'lib/api/**/*.rb'
- 'ee/lib/api/**/*.rb' - 'ee/lib/api/**/*.rb'
Graphql/Descriptions:
Enabled: true
Include:
- 'app/graphql/**/*'
- 'ee/app/graphql/**/*'
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Resolvers module Resolvers
class EchoResolver < BaseResolver class EchoResolver < BaseResolver
argument :text, GraphQL::STRING_TYPE, required: true argument :text, GraphQL::STRING_TYPE, required: true # rubocop:disable Graphql/Descriptions
description 'Testing endpoint to validate the API with' description 'Testing endpoint to validate the API with'
def resolve(**args) def resolve(**args)
......
...@@ -33,9 +33,9 @@ module Resolvers ...@@ -33,9 +33,9 @@ module Resolvers
argument :closed_after, Types::TimeType, argument :closed_after, Types::TimeType,
required: false, required: false,
description: "Issues closed after this date" description: "Issues closed after this date"
argument :search, GraphQL::STRING_TYPE, argument :search, GraphQL::STRING_TYPE, # rubocop:disable Graphql/Descriptions
required: false required: false
argument :sort, Types::Sort, argument :sort, Types::Sort, # rubocop:disable Graphql/Descriptions
required: false, required: false,
default_value: 'created_desc' default_value: 'created_desc'
......
...@@ -6,14 +6,14 @@ module Types ...@@ -6,14 +6,14 @@ module Types
class DetailedStatusType < BaseObject class DetailedStatusType < BaseObject
graphql_name 'DetailedStatus' graphql_name 'DetailedStatus'
field :group, GraphQL::STRING_TYPE, null: false field :group, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :icon, GraphQL::STRING_TYPE, null: false field :icon, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :favicon, GraphQL::STRING_TYPE, null: false field :favicon, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :details_path, GraphQL::STRING_TYPE, null: false field :details_path, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :has_details, GraphQL::BOOLEAN_TYPE, null: false, method: :has_details? field :has_details, GraphQL::BOOLEAN_TYPE, null: false, method: :has_details? # rubocop:disable Graphql/Descriptions
field :label, GraphQL::STRING_TYPE, null: false field :label, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :text, GraphQL::STRING_TYPE, null: false field :text, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :tooltip, GraphQL::STRING_TYPE, null: false, method: :status_tooltip field :tooltip, GraphQL::STRING_TYPE, null: false, method: :status_tooltip # rubocop:disable Graphql/Descriptions
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
end end
......
...@@ -9,13 +9,13 @@ module Types ...@@ -9,13 +9,13 @@ module Types
expose_permissions Types::PermissionTypes::Ci::Pipeline expose_permissions Types::PermissionTypes::Ci::Pipeline
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :iid, GraphQL::STRING_TYPE, null: false field :iid, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :sha, GraphQL::STRING_TYPE, null: false field :sha, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :before_sha, GraphQL::STRING_TYPE, null: true field :before_sha, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :status, PipelineStatusEnum, null: false field :status, PipelineStatusEnum, null: false # rubocop:disable Graphql/Descriptions
field :detailed_status, field :detailed_status, # rubocop:disable Graphql/Descriptions
Types::Ci::DetailedStatusType, Types::Ci::DetailedStatusType,
null: false, null: false,
resolve: -> (obj, _args, ctx) { obj.detailed_status(ctx[:current_user]) } resolve: -> (obj, _args, ctx) { obj.detailed_status(ctx[:current_user]) }
...@@ -27,11 +27,11 @@ module Types ...@@ -27,11 +27,11 @@ module Types
GraphQL::FLOAT_TYPE, GraphQL::FLOAT_TYPE,
null: true, null: true,
description: "Coverage percentage" description: "Coverage percentage"
field :created_at, Types::TimeType, null: false field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: false field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :started_at, Types::TimeType, null: true field :started_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :finished_at, Types::TimeType, null: true field :finished_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :committed_at, Types::TimeType, null: true field :committed_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
# TODO: Add triggering user as a type # TODO: Add triggering user as a type
end end
......
...@@ -8,16 +8,16 @@ module Types ...@@ -8,16 +8,16 @@ module Types
present_using CommitPresenter present_using CommitPresenter
field :id, type: GraphQL::ID_TYPE, null: false field :id, type: GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :sha, type: GraphQL::STRING_TYPE, null: false field :sha, type: GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :title, type: GraphQL::STRING_TYPE, null: true field :title, type: GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :description, type: GraphQL::STRING_TYPE, null: true field :description, type: GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :message, type: GraphQL::STRING_TYPE, null: true field :message, type: GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :authored_date, type: Types::TimeType, null: true field :authored_date, type: Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :web_url, type: GraphQL::STRING_TYPE, null: false field :web_url, type: GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
# models/commit lazy loads the author by email # models/commit lazy loads the author by email
field :author, type: Types::UserType, null: true field :author, type: Types::UserType, null: true # rubocop:disable Graphql/Descriptions
field :latest_pipeline, field :latest_pipeline,
type: Types::Ci::PipelineType, type: Types::Ci::PipelineType,
......
...@@ -8,13 +8,13 @@ module Types ...@@ -8,13 +8,13 @@ module Types
expose_permissions Types::PermissionTypes::Group expose_permissions Types::PermissionTypes::Group
field :web_url, GraphQL::STRING_TYPE, null: false field :web_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :avatar_url, GraphQL::STRING_TYPE, null: true, resolve: -> (group, args, ctx) do field :avatar_url, GraphQL::STRING_TYPE, null: true, resolve: -> (group, args, ctx) do # rubocop:disable Graphql/Descriptions
group.avatar_url(only_path: false) group.avatar_url(only_path: false)
end end
field :parent, GroupType, field :parent, GroupType, # rubocop:disable Graphql/Descriptions
null: true, null: true,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, obj.parent_id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, obj.parent_id).find }
end end
......
...@@ -12,49 +12,49 @@ module Types ...@@ -12,49 +12,49 @@ module Types
present_using IssuePresenter present_using IssuePresenter
field :iid, GraphQL::ID_TYPE, null: false field :iid, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :title, GraphQL::STRING_TYPE, null: false field :title, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
markdown_field :title_html, null: true markdown_field :title_html, null: true
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
markdown_field :description_html, null: true markdown_field :description_html, null: true
field :state, IssueStateEnum, null: false field :state, IssueStateEnum, null: false # rubocop:disable Graphql/Descriptions
field :reference, GraphQL::STRING_TYPE, null: false, method: :to_reference do field :reference, GraphQL::STRING_TYPE, null: false, method: :to_reference do # rubocop:disable Graphql/Descriptions
argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false # rubocop:disable Graphql/Descriptions
end end
field :author, Types::UserType, field :author, Types::UserType, # rubocop:disable Graphql/Descriptions
null: false, null: false,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find }
# Remove complexity when BatchLoader is used # Remove complexity when BatchLoader is used
field :assignees, Types::UserType.connection_type, null: true, complexity: 5 field :assignees, Types::UserType.connection_type, null: true, complexity: 5 # rubocop:disable Graphql/Descriptions
# Remove complexity when BatchLoader is used # Remove complexity when BatchLoader is used
field :labels, Types::LabelType.connection_type, null: true, complexity: 5 field :labels, Types::LabelType.connection_type, null: true, complexity: 5 # rubocop:disable Graphql/Descriptions
field :milestone, Types::MilestoneType, field :milestone, Types::MilestoneType, # rubocop:disable Graphql/Descriptions
null: true, null: true,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, obj.milestone_id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, obj.milestone_id).find }
field :due_date, Types::TimeType, null: true field :due_date, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :confidential, GraphQL::BOOLEAN_TYPE, null: false field :confidential, GraphQL::BOOLEAN_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :discussion_locked, GraphQL::BOOLEAN_TYPE, field :discussion_locked, GraphQL::BOOLEAN_TYPE, # rubocop:disable Graphql/Descriptions
null: false, null: false,
resolve: -> (obj, _args, _ctx) { !!obj.discussion_locked } resolve: -> (obj, _args, _ctx) { !!obj.discussion_locked }
field :upvotes, GraphQL::INT_TYPE, null: false field :upvotes, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :downvotes, GraphQL::INT_TYPE, null: false field :downvotes, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :user_notes_count, GraphQL::INT_TYPE, null: false field :user_notes_count, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :web_path, GraphQL::STRING_TYPE, null: false, method: :issue_path field :web_path, GraphQL::STRING_TYPE, null: false, method: :issue_path # rubocop:disable Graphql/Descriptions
field :web_url, GraphQL::STRING_TYPE, null: false field :web_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :relative_position, GraphQL::INT_TYPE, null: true field :relative_position, GraphQL::INT_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :closed_at, Types::TimeType, null: true field :closed_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :created_at, Types::TimeType, null: false field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: false field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :task_completion_status, Types::TaskCompletionStatus, null: false field :task_completion_status, Types::TaskCompletionStatus, null: false # rubocop:disable Graphql/Descriptions
end end
end end
......
...@@ -6,10 +6,10 @@ module Types ...@@ -6,10 +6,10 @@ module Types
authorize :read_label authorize :read_label
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
markdown_field :description_html, null: true markdown_field :description_html, null: true
field :title, GraphQL::STRING_TYPE, null: false field :title, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :color, GraphQL::STRING_TYPE, null: false field :color, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :text_color, GraphQL::STRING_TYPE, null: false field :text_color, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -12,53 +12,55 @@ module Types ...@@ -12,53 +12,55 @@ module Types
present_using MergeRequestPresenter present_using MergeRequestPresenter
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :iid, GraphQL::STRING_TYPE, null: false field :iid, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :title, GraphQL::STRING_TYPE, null: false field :title, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
markdown_field :title_html, null: true markdown_field :title_html, null: true
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
markdown_field :description_html, null: true markdown_field :description_html, null: true
field :state, MergeRequestStateEnum, null: false field :state, MergeRequestStateEnum, null: false # rubocop:disable Graphql/Descriptions
field :created_at, Types::TimeType, null: false field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: false field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :source_project, Types::ProjectType, null: true field :source_project, Types::ProjectType, null: true # rubocop:disable Graphql/Descriptions
field :target_project, Types::ProjectType, null: false field :target_project, Types::ProjectType, null: false # rubocop:disable Graphql/Descriptions
field :diff_refs, Types::DiffRefsType, null: true field :diff_refs, Types::DiffRefsType, null: true # rubocop:disable Graphql/Descriptions
# Alias for target_project # Alias for target_project
field :project, Types::ProjectType, null: false field :project, Types::ProjectType, null: false # rubocop:disable Graphql/Descriptions
field :project_id, GraphQL::INT_TYPE, null: false, method: :target_project_id field :project_id, GraphQL::INT_TYPE, null: false, method: :target_project_id # rubocop:disable Graphql/Descriptions
field :source_project_id, GraphQL::INT_TYPE, null: true field :source_project_id, GraphQL::INT_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :target_project_id, GraphQL::INT_TYPE, null: false field :target_project_id, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :source_branch, GraphQL::STRING_TYPE, null: false field :source_branch, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :target_branch, GraphQL::STRING_TYPE, null: false field :target_branch, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :work_in_progress, GraphQL::BOOLEAN_TYPE, method: :work_in_progress?, null: false field :work_in_progress, GraphQL::BOOLEAN_TYPE, method: :work_in_progress?, null: false # rubocop:disable Graphql/Descriptions
field :merge_when_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true field :merge_when_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :diff_head_sha, GraphQL::STRING_TYPE, null: true field :diff_head_sha, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :merge_commit_sha, GraphQL::STRING_TYPE, null: true field :merge_commit_sha, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :user_notes_count, GraphQL::INT_TYPE, null: true field :user_notes_count, GraphQL::INT_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :should_remove_source_branch, GraphQL::BOOLEAN_TYPE, method: :should_remove_source_branch?, null: true field :should_remove_source_branch, GraphQL::BOOLEAN_TYPE, method: :should_remove_source_branch?, null: true # rubocop:disable Graphql/Descriptions
field :force_remove_source_branch, GraphQL::BOOLEAN_TYPE, method: :force_remove_source_branch?, null: true field :force_remove_source_branch, GraphQL::BOOLEAN_TYPE, method: :force_remove_source_branch?, null: true # rubocop:disable Graphql/Descriptions
field :merge_status, GraphQL::STRING_TYPE, null: true field :merge_status, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :in_progress_merge_commit_sha, GraphQL::STRING_TYPE, null: true field :in_progress_merge_commit_sha, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :merge_error, GraphQL::STRING_TYPE, null: true field :merge_error, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :allow_collaboration, GraphQL::BOOLEAN_TYPE, null: true field :allow_collaboration, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :should_be_rebased, GraphQL::BOOLEAN_TYPE, method: :should_be_rebased?, null: false field :should_be_rebased, GraphQL::BOOLEAN_TYPE, method: :should_be_rebased?, null: false # rubocop:disable Graphql/Descriptions
field :rebase_commit_sha, GraphQL::STRING_TYPE, null: true field :rebase_commit_sha, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true # rubocop:disable Graphql/Descriptions
# rubocop:disable Graphql/Descriptions
field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true, deprecation_reason: "Renamed to defaultMergeCommitMessage" field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true, deprecation_reason: "Renamed to defaultMergeCommitMessage"
field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true # rubocop:enable Graphql/Descriptions
field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :source_branch_exists, GraphQL::BOOLEAN_TYPE, method: :source_branch_exists?, null: false field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false # rubocop:disable Graphql/Descriptions
field :mergeable_discussions_state, GraphQL::BOOLEAN_TYPE, null: true field :source_branch_exists, GraphQL::BOOLEAN_TYPE, method: :source_branch_exists?, null: false # rubocop:disable Graphql/Descriptions
field :web_url, GraphQL::STRING_TYPE, null: true field :mergeable_discussions_state, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :upvotes, GraphQL::INT_TYPE, null: false field :web_url, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :downvotes, GraphQL::INT_TYPE, null: false field :upvotes, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false field :downvotes, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false # rubocop:disable Graphql/Descriptions
field :head_pipeline, Types::Ci::PipelineType, null: true, method: :actual_head_pipeline field :head_pipeline, Types::Ci::PipelineType, null: true, method: :actual_head_pipeline # rubocop:disable Graphql/Descriptions
field :pipelines, Types::Ci::PipelineType.connection_type, field :pipelines, Types::Ci::PipelineType.connection_type, # rubocop:disable Graphql/Descriptions
resolver: Resolvers::MergeRequestPipelinesResolver resolver: Resolvers::MergeRequestPipelinesResolver
field :task_completion_status, Types::TaskCompletionStatus, null: false field :task_completion_status, Types::TaskCompletionStatus, null: false # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -6,7 +6,7 @@ module Types ...@@ -6,7 +6,7 @@ module Types
authorize :read_instance_metadata authorize :read_instance_metadata
field :version, GraphQL::STRING_TYPE, null: false field :version, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :revision, GraphQL::STRING_TYPE, null: false field :revision, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -6,14 +6,14 @@ module Types ...@@ -6,14 +6,14 @@ module Types
authorize :read_milestone authorize :read_milestone
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :title, GraphQL::STRING_TYPE, null: false field :title, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :state, GraphQL::STRING_TYPE, null: false field :state, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :due_date, Types::TimeType, null: true field :due_date, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :start_date, Types::TimeType, null: true field :start_date, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :created_at, Types::TimeType, null: false field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: false field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -6,25 +6,25 @@ module Types ...@@ -6,25 +6,25 @@ module Types
authorize :read_namespace authorize :read_namespace
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :name, GraphQL::STRING_TYPE, null: false field :name, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :path, GraphQL::STRING_TYPE, null: false field :path, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :full_name, GraphQL::STRING_TYPE, null: false field :full_name, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :full_path, GraphQL::ID_TYPE, null: false field :full_path, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
markdown_field :description_html, null: true markdown_field :description_html, null: true
field :visibility, GraphQL::STRING_TYPE, null: true field :visibility, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true, method: :lfs_enabled? field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true, method: :lfs_enabled? # rubocop:disable Graphql/Descriptions
field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :root_storage_statistics, Types::RootStorageStatisticsType, field :root_storage_statistics, Types::RootStorageStatisticsType,
null: true, null: true,
description: 'The aggregated storage statistics. Only available for root namespaces', description: 'The aggregated storage statistics. Only available for root namespaces',
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchRootStorageStatisticsLoader.new(obj.id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchRootStorageStatisticsLoader.new(obj.id).find }
field :projects, field :projects, # rubocop:disable Graphql/Descriptions
Types::ProjectType.connection_type, Types::ProjectType.connection_type,
null: false, null: false,
resolver: ::Resolvers::NamespaceProjectsResolver resolver: ::Resolvers::NamespaceProjectsResolver
......
...@@ -7,7 +7,7 @@ module Types ...@@ -7,7 +7,7 @@ module Types
class DiffPositionType < BaseObject class DiffPositionType < BaseObject
graphql_name 'DiffPosition' graphql_name 'DiffPosition'
field :diff_refs, Types::DiffRefsType, null: false field :diff_refs, Types::DiffRefsType, null: false # rubocop:disable Graphql/Descriptions
field :file_path, GraphQL::STRING_TYPE, null: false, field :file_path, GraphQL::STRING_TYPE, null: false,
description: "The path of the file that was changed" description: "The path of the file that was changed"
...@@ -15,7 +15,7 @@ module Types ...@@ -15,7 +15,7 @@ module Types
description: "The path of the file on the start sha." description: "The path of the file on the start sha."
field :new_path, GraphQL::STRING_TYPE, null: true, field :new_path, GraphQL::STRING_TYPE, null: true,
description: "The path of the file on the head sha." description: "The path of the file on the head sha."
field :position_type, Types::Notes::PositionTypeEnum, null: false field :position_type, Types::Notes::PositionTypeEnum, null: false # rubocop:disable Graphql/Descriptions
# Fields for text positions # Fields for text positions
field :old_line, GraphQL::INT_TYPE, null: true, field :old_line, GraphQL::INT_TYPE, null: true,
......
...@@ -7,9 +7,9 @@ module Types ...@@ -7,9 +7,9 @@ module Types
authorize :read_note authorize :read_note
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :reply_id, GraphQL::ID_TYPE, null: false, description: 'The ID used to reply to this discussion' field :reply_id, GraphQL::ID_TYPE, null: false, description: 'The ID used to reply to this discussion'
field :created_at, Types::TimeType, null: false field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :notes, Types::Notes::NoteType.connection_type, null: false, description: "All notes in the discussion" field :notes, Types::Notes::NoteType.connection_type, null: false, description: "All notes in the discussion"
# The gem we use to generate Global IDs is hard-coded to work with # The gem we use to generate Global IDs is hard-coded to work with
......
...@@ -9,7 +9,7 @@ module Types ...@@ -9,7 +9,7 @@ module Types
expose_permissions Types::PermissionTypes::Note expose_permissions Types::PermissionTypes::Note
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :project, Types::ProjectType, field :project, Types::ProjectType,
null: true, null: true,
...@@ -37,10 +37,10 @@ module Types ...@@ -37,10 +37,10 @@ module Types
markdown_field :body_html, null: true, method: :note markdown_field :body_html, null: true, method: :note
field :created_at, Types::TimeType, null: false field :created_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: false field :updated_at, Types::TimeType, null: false # rubocop:disable Graphql/Descriptions
field :discussion, Types::Notes::DiscussionType, null: true, description: "The discussion this note is a part of" field :discussion, Types::Notes::DiscussionType, null: true, description: "The discussion this note is a part of"
field :resolvable, GraphQL::BOOLEAN_TYPE, null: false, method: :resolvable? field :resolvable, GraphQL::BOOLEAN_TYPE, null: false, method: :resolvable? # rubocop:disable Graphql/Descriptions
field :resolved_at, Types::TimeType, null: true, description: "The time the discussion was resolved" field :resolved_at, Types::TimeType, null: true, description: "The time the discussion was resolved"
field :position, Types::Notes::DiffPositionType, null: true, description: "The position of this note on a diff" field :position, Types::Notes::DiffPositionType, null: true, description: "The position of this note on a diff"
end end
......
...@@ -28,7 +28,7 @@ module Types ...@@ -28,7 +28,7 @@ module Types
description: "Whether or not a user can perform `#{name}` on this resource", description: "Whether or not a user can perform `#{name}` on this resource",
null: false) null: false)
field(**kword_args) field(**kword_args) # rubocop:disable Graphql/Descriptions
end end
def self.resolving_keywords?(arguments) def self.resolving_keywords?(arguments)
......
...@@ -6,13 +6,13 @@ module Types ...@@ -6,13 +6,13 @@ module Types
authorize :read_statistics authorize :read_statistics
field :commit_count, GraphQL::INT_TYPE, null: false field :commit_count, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :storage_size, GraphQL::INT_TYPE, null: false field :storage_size, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :repository_size, GraphQL::INT_TYPE, null: false field :repository_size, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :lfs_objects_size, GraphQL::INT_TYPE, null: false field :lfs_objects_size, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :build_artifacts_size, GraphQL::INT_TYPE, null: false field :build_artifacts_size, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :packages_size, GraphQL::INT_TYPE, null: false field :packages_size, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :wiki_size, GraphQL::INT_TYPE, null: true field :wiki_size, GraphQL::INT_TYPE, null: true # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -8,95 +8,95 @@ module Types ...@@ -8,95 +8,95 @@ module Types
expose_permissions Types::PermissionTypes::Project expose_permissions Types::PermissionTypes::Project
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :full_path, GraphQL::ID_TYPE, null: false field :full_path, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :path, GraphQL::STRING_TYPE, null: false field :path, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :name_with_namespace, GraphQL::STRING_TYPE, null: false field :name_with_namespace, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :name, GraphQL::STRING_TYPE, null: false field :name, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
markdown_field :description_html, null: true markdown_field :description_html, null: true
field :tag_list, GraphQL::STRING_TYPE, null: true field :tag_list, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :ssh_url_to_repo, GraphQL::STRING_TYPE, null: true field :ssh_url_to_repo, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :http_url_to_repo, GraphQL::STRING_TYPE, null: true field :http_url_to_repo, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :web_url, GraphQL::STRING_TYPE, null: true field :web_url, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :star_count, GraphQL::INT_TYPE, null: false field :star_count, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :forks_count, GraphQL::INT_TYPE, null: false, calls_gitaly: true # 4 times field :forks_count, GraphQL::INT_TYPE, null: false, calls_gitaly: true # 4 times # rubocop:disable Graphql/Descriptions
field :created_at, Types::TimeType, null: true field :created_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :last_activity_at, Types::TimeType, null: true field :last_activity_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :archived, GraphQL::BOOLEAN_TYPE, null: true field :archived, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :visibility, GraphQL::STRING_TYPE, null: true field :visibility, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :container_registry_enabled, GraphQL::BOOLEAN_TYPE, null: true field :container_registry_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :shared_runners_enabled, GraphQL::BOOLEAN_TYPE, null: true field :shared_runners_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :merge_requests_ff_only_enabled, GraphQL::BOOLEAN_TYPE, null: true field :merge_requests_ff_only_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :avatar_url, GraphQL::STRING_TYPE, null: true, calls_gitaly: true, resolve: -> (project, args, ctx) do field :avatar_url, GraphQL::STRING_TYPE, null: true, calls_gitaly: true, resolve: -> (project, args, ctx) do # rubocop:disable Graphql/Descriptions
project.avatar_url(only_path: false) project.avatar_url(only_path: false)
end end
%i[issues merge_requests wiki snippets].each do |feature| %i[issues merge_requests wiki snippets].each do |feature|
field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do # rubocop:disable Graphql/Descriptions
project.feature_available?(feature, ctx[:current_user]) project.feature_available?(feature, ctx[:current_user])
end end
end end
field :jobs_enabled, GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do field :jobs_enabled, GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do # rubocop:disable Graphql/Descriptions
project.feature_available?(:builds, ctx[:current_user]) project.feature_available?(:builds, ctx[:current_user])
end end
field :public_jobs, GraphQL::BOOLEAN_TYPE, method: :public_builds, null: true field :public_jobs, GraphQL::BOOLEAN_TYPE, method: :public_builds, null: true # rubocop:disable Graphql/Descriptions
field :open_issues_count, GraphQL::INT_TYPE, null: true, resolve: -> (project, args, ctx) do field :open_issues_count, GraphQL::INT_TYPE, null: true, resolve: -> (project, args, ctx) do # rubocop:disable Graphql/Descriptions
project.open_issues_count if project.feature_available?(:issues, ctx[:current_user]) project.open_issues_count if project.feature_available?(:issues, ctx[:current_user])
end end
field :import_status, GraphQL::STRING_TYPE, null: true field :import_status, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :only_allow_merge_if_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true field :only_allow_merge_if_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :only_allow_merge_if_all_discussions_are_resolved, GraphQL::BOOLEAN_TYPE, null: true field :only_allow_merge_if_all_discussions_are_resolved, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :printing_merge_request_link_enabled, GraphQL::BOOLEAN_TYPE, null: true field :printing_merge_request_link_enabled, GraphQL::BOOLEAN_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :namespace, Types::NamespaceType, null: true field :namespace, Types::NamespaceType, null: true # rubocop:disable Graphql/Descriptions
field :group, Types::GroupType, null: true field :group, Types::GroupType, null: true # rubocop:disable Graphql/Descriptions
field :statistics, Types::ProjectStatisticsType, field :statistics, Types::ProjectStatisticsType, # rubocop:disable Graphql/Descriptions
null: true, null: true,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchProjectStatisticsLoader.new(obj.id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchProjectStatisticsLoader.new(obj.id).find }
field :repository, Types::RepositoryType, null: true field :repository, Types::RepositoryType, null: true # rubocop:disable Graphql/Descriptions
field :merge_requests, field :merge_requests, # rubocop:disable Graphql/Descriptions
Types::MergeRequestType.connection_type, Types::MergeRequestType.connection_type,
null: true, null: true,
resolver: Resolvers::MergeRequestsResolver resolver: Resolvers::MergeRequestsResolver
field :merge_request, field :merge_request, # rubocop:disable Graphql/Descriptions
Types::MergeRequestType, Types::MergeRequestType,
null: true, null: true,
resolver: Resolvers::MergeRequestsResolver.single resolver: Resolvers::MergeRequestsResolver.single
field :issues, field :issues, # rubocop:disable Graphql/Descriptions
Types::IssueType.connection_type, Types::IssueType.connection_type,
null: true, null: true,
resolver: Resolvers::IssuesResolver resolver: Resolvers::IssuesResolver
field :issue, field :issue, # rubocop:disable Graphql/Descriptions
Types::IssueType, Types::IssueType,
null: true, null: true,
resolver: Resolvers::IssuesResolver.single resolver: Resolvers::IssuesResolver.single
field :pipelines, field :pipelines, # rubocop:disable Graphql/Descriptions
Types::Ci::PipelineType.connection_type, Types::Ci::PipelineType.connection_type,
null: true, null: true,
resolver: Resolvers::ProjectPipelinesResolver resolver: Resolvers::ProjectPipelinesResolver
......
...@@ -24,6 +24,6 @@ module Types ...@@ -24,6 +24,6 @@ module Types
resolver: Resolvers::MetadataResolver, resolver: Resolvers::MetadataResolver,
description: 'Metadata about GitLab' description: 'Metadata about GitLab'
field :echo, GraphQL::STRING_TYPE, null: false, resolver: Resolvers::EchoResolver field :echo, GraphQL::STRING_TYPE, null: false, resolver: Resolvers::EchoResolver # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -6,9 +6,9 @@ module Types ...@@ -6,9 +6,9 @@ module Types
authorize :download_code authorize :download_code
field :root_ref, GraphQL::STRING_TYPE, null: true, calls_gitaly: true field :root_ref, GraphQL::STRING_TYPE, null: true, calls_gitaly: true # rubocop:disable Graphql/Descriptions
field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true # rubocop:disable Graphql/Descriptions
field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists? field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists? # rubocop:disable Graphql/Descriptions
field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -8,8 +8,8 @@ module Types ...@@ -8,8 +8,8 @@ module Types
graphql_name 'TaskCompletionStatus' graphql_name 'TaskCompletionStatus'
description 'Completion status of tasks' description 'Completion status of tasks'
field :count, GraphQL::INT_TYPE, null: false field :count, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :completed_count, GraphQL::INT_TYPE, null: false field :completed_count, GraphQL::INT_TYPE, null: false # rubocop:disable Graphql/Descriptions
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
end end
...@@ -10,8 +10,8 @@ module Types ...@@ -10,8 +10,8 @@ module Types
graphql_name 'Blob' graphql_name 'Blob'
field :web_url, GraphQL::STRING_TYPE, null: true field :web_url, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :lfs_oid, GraphQL::STRING_TYPE, null: true, resolve: -> (blob, args, ctx) do field :lfs_oid, GraphQL::STRING_TYPE, null: true, resolve: -> (blob, args, ctx) do # rubocop:disable Graphql/Descriptions
Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(blob.repository, blob.id).find Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(blob.repository, blob.id).find
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
......
...@@ -4,11 +4,11 @@ module Types ...@@ -4,11 +4,11 @@ module Types
module EntryType module EntryType
include Types::BaseInterface include Types::BaseInterface
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :name, GraphQL::STRING_TYPE, null: false field :name, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :type, Tree::TypeEnum, null: false field :type, Tree::TypeEnum, null: false # rubocop:disable Graphql/Descriptions
field :path, GraphQL::STRING_TYPE, null: false field :path, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :flat_path, GraphQL::STRING_TYPE, null: false field :flat_path, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
end end
end end
end end
...@@ -8,8 +8,8 @@ module Types ...@@ -8,8 +8,8 @@ module Types
graphql_name 'Submodule' graphql_name 'Submodule'
field :web_url, type: GraphQL::STRING_TYPE, null: true field :web_url, type: GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :tree_url, type: GraphQL::STRING_TYPE, null: true field :tree_url, type: GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
end end
......
...@@ -11,7 +11,7 @@ module Types ...@@ -11,7 +11,7 @@ module Types
graphql_name 'TreeEntry' graphql_name 'TreeEntry'
description 'Represents a directory' description 'Represents a directory'
field :web_url, GraphQL::STRING_TYPE, null: true field :web_url, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
end end
......
...@@ -7,19 +7,21 @@ module Types ...@@ -7,19 +7,21 @@ module Types
graphql_name 'Tree' graphql_name 'Tree'
# Complexity 10 as it triggers a Gitaly call on each render # Complexity 10 as it triggers a Gitaly call on each render
field :last_commit, Types::CommitType, null: true, complexity: 10, calls_gitaly: true, resolve: -> (tree, args, ctx) do field :last_commit, Types::CommitType, null: true, complexity: 10, calls_gitaly: true, resolve: -> (tree, args, ctx) do # rubocop:disable Graphql/Descriptions
tree.repository.last_commit_for_path(tree.sha, tree.path) tree.repository.last_commit_for_path(tree.sha, tree.path)
end end
field :trees, Types::Tree::TreeEntryType.connection_type, null: false, resolve: -> (obj, args, ctx) do field :trees, Types::Tree::TreeEntryType.connection_type, null: false, resolve: -> (obj, args, ctx) do # rubocop:disable Graphql/Descriptions
Gitlab::Graphql::Representation::TreeEntry.decorate(obj.trees, obj.repository) Gitlab::Graphql::Representation::TreeEntry.decorate(obj.trees, obj.repository)
end end
# rubocop:disable Graphql/Descriptions
field :submodules, Types::Tree::SubmoduleType.connection_type, null: false, calls_gitaly: true, resolve: -> (obj, args, ctx) do field :submodules, Types::Tree::SubmoduleType.connection_type, null: false, calls_gitaly: true, resolve: -> (obj, args, ctx) do
Gitlab::Graphql::Representation::SubmoduleTreeEntry.decorate(obj.submodules, obj) Gitlab::Graphql::Representation::SubmoduleTreeEntry.decorate(obj.submodules, obj)
end end
# rubocop:enable Graphql/Descriptions
field :blobs, Types::Tree::BlobType.connection_type, null: false, calls_gitaly: true, resolve: -> (obj, args, ctx) do field :blobs, Types::Tree::BlobType.connection_type, null: false, calls_gitaly: true, resolve: -> (obj, args, ctx) do # rubocop:disable Graphql/Descriptions
Gitlab::Graphql::Representation::TreeEntry.decorate(obj.blobs, obj.repository) Gitlab::Graphql::Representation::TreeEntry.decorate(obj.blobs, obj.repository)
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
......
...@@ -8,9 +8,9 @@ module Types ...@@ -8,9 +8,9 @@ module Types
present_using UserPresenter present_using UserPresenter
field :name, GraphQL::STRING_TYPE, null: false field :name, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :username, GraphQL::STRING_TYPE, null: false field :username, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :avatar_url, GraphQL::STRING_TYPE, null: false field :avatar_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :web_url, GraphQL::STRING_TYPE, null: false field :web_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
end end
end end
...@@ -7,17 +7,17 @@ module EE ...@@ -7,17 +7,17 @@ module EE
prepended do prepended do
%i[epics].each do |feature| %i[epics].each do |feature|
field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (group, args, ctx) do field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (group, args, ctx) do # rubocop:disable Graphql/Descriptions
group.feature_available?(feature) group.feature_available?(feature)
end end
end end
field :epic, field :epic, # rubocop:disable Graphql/Descriptions
::Types::EpicType, ::Types::EpicType,
null: true, null: true,
resolver: ::Resolvers::EpicResolver.single resolver: ::Resolvers::EpicResolver.single
field :epics, field :epics, # rubocop:disable Graphql/Descriptions
::Types::EpicType.connection_type, ::Types::EpicType.connection_type,
null: true, null: true,
resolver: ::Resolvers::EpicResolver resolver: ::Resolvers::EpicResolver
......
...@@ -6,15 +6,15 @@ module EE ...@@ -6,15 +6,15 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do prepended do
field :weight, GraphQL::INT_TYPE, field :weight, GraphQL::INT_TYPE, # rubocop:disable Graphql/Descriptions
null: true, null: true,
resolve: -> (obj, _args, _ctx) { obj.supports_weight? ? obj.weight : nil } resolve: -> (obj, _args, _ctx) { obj.supports_weight? ? obj.weight : nil }
field :designs, ::Types::DesignManagement::DesignCollectionType, field :designs, ::Types::DesignManagement::DesignCollectionType, # rubocop:disable Graphql/Descriptions
null: true, method: :design_collection, null: true, method: :design_collection,
deprecation_reason: 'use design_collection' deprecation_reason: 'use design_collection'
field :design_collection, ::Types::DesignManagement::DesignCollectionType, null: true field :design_collection, ::Types::DesignManagement::DesignCollectionType, null: true # rubocop:disable Graphql/Descriptions
end end
end end
end end
......
...@@ -7,8 +7,8 @@ module Types ...@@ -7,8 +7,8 @@ module Types
authorize :read_design authorize :read_design
field :project, Types::ProjectType, null: false field :project, Types::ProjectType, null: false # rubocop:disable Graphql/Descriptions
field :issue, Types::IssueType, null: false field :issue, Types::IssueType, null: false # rubocop:disable Graphql/Descriptions
field :designs, field :designs,
Types::DesignManagement::DesignType.connection_type, Types::DesignManagement::DesignType.connection_type,
null: false, null: false,
......
...@@ -11,23 +11,23 @@ module Types ...@@ -11,23 +11,23 @@ module Types
alias_method :design, :object alias_method :design, :object
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :project, Types::ProjectType, null: false field :project, Types::ProjectType, null: false # rubocop:disable Graphql/Descriptions
field :issue, Types::IssueType, null: false field :issue, Types::IssueType, null: false # rubocop:disable Graphql/Descriptions
field :notes_count, field :notes_count,
GraphQL::INT_TYPE, GraphQL::INT_TYPE,
null: false, null: false,
method: :user_notes_count, method: :user_notes_count,
description: 'The total count of user-created notes for this design' description: 'The total count of user-created notes for this design'
field :filename, GraphQL::STRING_TYPE, null: false field :filename, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :full_path, GraphQL::STRING_TYPE, null: false field :full_path, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :event, field :event,
Types::DesignManagement::DesignVersionEventEnum, Types::DesignManagement::DesignVersionEventEnum,
null: false, null: false,
description: 'The change that happened to the design at this version', description: 'The change that happened to the design at this version',
extras: [:parent] extras: [:parent]
field :image, GraphQL::STRING_TYPE, null: false, extras: [:parent] field :image, GraphQL::STRING_TYPE, null: false, extras: [:parent] # rubocop:disable Graphql/Descriptions
field :diff_refs, Types::DiffRefsType, null: false, calls_gitaly: true field :diff_refs, Types::DiffRefsType, null: false, calls_gitaly: true # rubocop:disable Graphql/Descriptions
field :versions, field :versions,
Types::DesignManagement::VersionType.connection_type, Types::DesignManagement::VersionType.connection_type,
resolver: Resolvers::DesignManagement::VersionResolver, resolver: Resolvers::DesignManagement::VersionResolver,
......
...@@ -9,8 +9,8 @@ module Types ...@@ -9,8 +9,8 @@ module Types
authorize :read_design authorize :read_design
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :sha, GraphQL::ID_TYPE, null: false field :sha, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :designs, field :designs,
Types::DesignManagement::DesignType.connection_type, Types::DesignManagement::DesignType.connection_type,
null: false, null: false,
......
...@@ -8,9 +8,9 @@ module Types ...@@ -8,9 +8,9 @@ module Types
present_using EpicIssuePresenter present_using EpicIssuePresenter
field :epic_issue_id, GraphQL::ID_TYPE, null: false field :epic_issue_id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :relation_path, GraphQL::STRING_TYPE, null: true, resolve: -> (issue, args, ctx) do field :relation_path, GraphQL::STRING_TYPE, null: true, resolve: -> (issue, args, ctx) do # rubocop:disable Graphql/Descriptions
issue.group_epic_issue_path(ctx[:current_user]) issue.group_epic_issue_path(ctx[:current_user])
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
......
...@@ -12,52 +12,52 @@ module Types ...@@ -12,52 +12,52 @@ module Types
implements(Types::Notes::NoteableType) implements(Types::Notes::NoteableType)
field :id, GraphQL::ID_TYPE, null: false field :id, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :iid, GraphQL::ID_TYPE, null: false field :iid, GraphQL::ID_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :title, GraphQL::STRING_TYPE, null: true field :title, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :description, GraphQL::STRING_TYPE, null: true field :description, GraphQL::STRING_TYPE, null: true # rubocop:disable Graphql/Descriptions
field :state, EpicStateEnum, null: false field :state, EpicStateEnum, null: false # rubocop:disable Graphql/Descriptions
field :group, GroupType, field :group, GroupType, # rubocop:disable Graphql/Descriptions
null: false, null: false,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, obj.group_id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, obj.group_id).find }
field :parent, EpicType, field :parent, EpicType, # rubocop:disable Graphql/Descriptions
null: true, null: true,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Epic, obj.parent_id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Epic, obj.parent_id).find }
field :author, Types::UserType, field :author, Types::UserType, # rubocop:disable Graphql/Descriptions
null: false, null: false,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find } resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find }
field :start_date, Types::TimeType, null: true field :start_date, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :start_date_is_fixed, GraphQL::BOOLEAN_TYPE, null: true, method: :start_date_is_fixed?, authorize: :admin_epic field :start_date_is_fixed, GraphQL::BOOLEAN_TYPE, null: true, method: :start_date_is_fixed?, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :start_date_fixed, Types::TimeType, null: true, authorize: :admin_epic field :start_date_fixed, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :start_date_from_milestones, Types::TimeType, null: true, authorize: :admin_epic field :start_date_from_milestones, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :due_date, Types::TimeType, null: true field :due_date, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :due_date_is_fixed, GraphQL::BOOLEAN_TYPE, null: true, method: :due_date_is_fixed?, authorize: :admin_epic field :due_date_is_fixed, GraphQL::BOOLEAN_TYPE, null: true, method: :due_date_is_fixed?, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :due_date_fixed, Types::TimeType, null: true, authorize: :admin_epic field :due_date_fixed, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :due_date_from_milestones, Types::TimeType, null: true, authorize: :admin_epic field :due_date_from_milestones, Types::TimeType, null: true, authorize: :admin_epic # rubocop:disable Graphql/Descriptions
field :closed_at, Types::TimeType, null: true field :closed_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :created_at, Types::TimeType, null: true field :created_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :updated_at, Types::TimeType, null: true field :updated_at, Types::TimeType, null: true # rubocop:disable Graphql/Descriptions
field :children, field :children, # rubocop:disable Graphql/Descriptions
::Types::EpicType.connection_type, ::Types::EpicType.connection_type,
null: true, null: true,
resolver: ::Resolvers::EpicResolver resolver: ::Resolvers::EpicResolver
field :has_children, GraphQL::BOOLEAN_TYPE, null: false, method: :has_children? field :has_children, GraphQL::BOOLEAN_TYPE, null: false, method: :has_children? # rubocop:disable Graphql/Descriptions
field :has_issues, GraphQL::BOOLEAN_TYPE, null: false, method: :has_issues? field :has_issues, GraphQL::BOOLEAN_TYPE, null: false, method: :has_issues? # rubocop:disable Graphql/Descriptions
field :web_path, GraphQL::STRING_TYPE, null: false, method: :group_epic_path field :web_path, GraphQL::STRING_TYPE, null: false, method: :group_epic_path # rubocop:disable Graphql/Descriptions
field :web_url, GraphQL::STRING_TYPE, null: false, method: :group_epic_url field :web_url, GraphQL::STRING_TYPE, null: false, method: :group_epic_url # rubocop:disable Graphql/Descriptions
field :relation_path, GraphQL::STRING_TYPE, null: true, method: :group_epic_link_path field :relation_path, GraphQL::STRING_TYPE, null: true, method: :group_epic_link_path # rubocop:disable Graphql/Descriptions
field :reference, GraphQL::STRING_TYPE, null: false, method: :epic_reference do field :reference, GraphQL::STRING_TYPE, null: false, method: :epic_reference do # rubocop:disable Graphql/Descriptions
argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false # rubocop:disable Graphql/Descriptions
end end
field :issues, field :issues, # rubocop:disable Graphql/Descriptions
Types::EpicIssueType.connection_type, Types::EpicIssueType.connection_type,
null: true, null: true,
resolver: Resolvers::EpicIssuesResolver resolver: Resolvers::EpicIssuesResolver
......
...@@ -30,7 +30,7 @@ module RuboCop ...@@ -30,7 +30,7 @@ module RuboCop
def in_type?(node) def in_type?(node)
path = node.location.expression.source_buffer.name path = node.location.expression.source_buffer.name
path.include?(TYPES_DIR) path.include? TYPES_DIR
end end
def whitelisted?(class_node) def whitelisted?(class_node)
...@@ -44,7 +44,7 @@ module RuboCop ...@@ -44,7 +44,7 @@ module RuboCop
end end
def superclass_constant(class_node) def superclass_constant(class_node)
# First one is the class name itself, second is it's superclass # First one is the class name itself, second is its superclass
_class_constant, *others = class_node.descendants _class_constant, *others = class_node.descendants
others.find { |node| node.const_type? && node&.const_name != 'Types' } others.find { |node| node.const_type? && node&.const_name != 'Types' }
......
# frozen_string_literal: true
# This cop checks for missing GraphQL field descriptions.
#
# @example
#
# # bad
# class AwfulClass
# field :some_field, GraphQL::STRING_TYPE
# end
#
# class TerribleClass
# argument :some_argument, GraphQL::STRING_TYPE
# end
#
# # good
# class GreatClass
# argument :some_field,
# GraphQL::STRING_TYPE,
# description: "Well described - a superb description"
#
# field :some_field,
# GraphQL::STRING_TYPE,
# description: "A thorough and compelling description"
# end
module RuboCop
module Cop
module Graphql
class Descriptions < RuboCop::Cop::Cop
MSG = 'Please add a `description` property.'
# ability_field and permission_field set a default description.
def_node_matcher :fields, <<~PATTERN
(send nil? :field $...)
PATTERN
def_node_matcher :arguments, <<~PATTERN
(send nil? :argument $...)
PATTERN
def_node_matcher :has_description?, <<~PATTERN
(hash <(pair (sym :description) _) ...>)
PATTERN
def on_send(node)
matches = fields(node) || arguments(node)
return if matches.nil?
add_offense(node, location: :expression) unless has_description?(matches.last)
end
end
end
end
end
...@@ -49,3 +49,4 @@ require_relative 'cop/code_reuse/active_record' ...@@ -49,3 +49,4 @@ require_relative 'cop/code_reuse/active_record'
require_relative 'cop/group_public_or_visible_to_user' require_relative 'cop/group_public_or_visible_to_user'
require_relative 'cop/inject_enterprise_edition_module' require_relative 'cop/inject_enterprise_edition_module'
require_relative 'cop/graphql/authorize_types' require_relative 'cop/graphql/authorize_types'
require_relative 'cop/graphql/descriptions'
...@@ -11,6 +11,23 @@ describe RuboCop::Cop::Graphql::AuthorizeTypes do ...@@ -11,6 +11,23 @@ describe RuboCop::Cop::Graphql::AuthorizeTypes do
subject(:cop) { described_class.new } subject(:cop) { described_class.new }
context 'when NOT in a type folder' do
before do
allow(cop).to receive(:in_type?).and_return(false)
end
it 'does not add an offense even though there is no authorize call' do
expect_no_offenses(<<~TYPE.strip)
module Types
class AType < BaseObject
field :a_thing
field :another_thing
end
end
TYPE
end
end
context 'when in a type folder' do context 'when in a type folder' do
before do before do
allow(cop).to receive(:in_type?).and_return(true) allow(cop).to receive(:in_type?).and_return(true)
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/graphql/descriptions'
describe RuboCop::Cop::Graphql::Descriptions do
include RuboCop::RSpec::ExpectOffense
include CopHelper
subject(:cop) { described_class.new }
context 'fields' do
it 'adds an offense when there is no field description' do
inspect_source(<<~TYPE)
module Types
class FakeType < BaseObject
field :a_thing,
GraphQL::STRING_TYPE,
null: false
end
end
TYPE
expect(cop.offenses.size).to eq 1
end
it 'does not add an offense for fields with a description' do
expect_no_offenses(<<~TYPE.strip)
module Types
class FakeType < BaseObject
graphql_name 'FakeTypeName'
argument :a_thing,
GraphQL::STRING_TYPE,
null: false,
description: 'A descriptive description'
end
end
TYPE
end
end
context 'arguments' do
it 'adds an offense when there is no argument description' do
inspect_source(<<~TYPE)
module Types
class FakeType < BaseObject
argument :a_thing,
GraphQL::STRING_TYPE,
null: false
end
end
TYPE
expect(cop.offenses.size).to eq 1
end
it 'does not add an offense for arguments with a description' do
expect_no_offenses(<<~TYPE.strip)
module Types
class FakeType < BaseObject
graphql_name 'FakeTypeName'
argument :a_thing,
GraphQL::STRING_TYPE,
null: false,
description: 'Behold! A description'
end
end
TYPE
end
end
end
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