Commit 45e72f88 authored by David O'Regan's avatar David O'Regan

Merge branch '346029-Fix-GraphQL/FieldDefinitions-offense-(Part-3/4)' into 'master'

Fix GraphQL/FieldDefinitions offense (Part 3/4)

See merge request gitlab-org/gitlab!76016
parents c0492a93 e3939b1b
...@@ -5,9 +5,6 @@ GraphQL/FieldDefinitions: ...@@ -5,9 +5,6 @@ GraphQL/FieldDefinitions:
- app/graphql/types/group_type.rb - app/graphql/types/group_type.rb
- app/graphql/types/issue_type.rb - app/graphql/types/issue_type.rb
- app/graphql/types/label_type.rb - app/graphql/types/label_type.rb
- app/graphql/types/project_type.rb
- app/graphql/types/projects/topic_type.rb
- app/graphql/types/release_type.rb
- ee/app/graphql/types/ci/code_quality_degradation_type.rb - ee/app/graphql/types/ci/code_quality_degradation_type.rb
- ee/app/graphql/types/epic_type.rb - ee/app/graphql/types/epic_type.rb
- ee/app/graphql/types/group_release_stats_type.rb - ee/app/graphql/types/group_release_stats_type.rb
......
...@@ -27,7 +27,6 @@ module Types ...@@ -27,7 +27,6 @@ module Types
field :description, GraphQL::Types::String, null: true, field :description, GraphQL::Types::String, null: true,
description: 'Short description of the project.' description: 'Short description of the project.'
markdown_field :description_html, null: true
field :tag_list, GraphQL::Types::String, null: true, field :tag_list, GraphQL::Types::String, null: true,
deprecated: { reason: 'Use `topics`', milestone: '13.12' }, deprecated: { reason: 'Use `topics`', milestone: '13.12' },
...@@ -75,21 +74,6 @@ module Types ...@@ -75,21 +74,6 @@ module Types
field :avatar_url, GraphQL::Types::String, null: true, calls_gitaly: true, field :avatar_url, GraphQL::Types::String, null: true, calls_gitaly: true,
description: 'URL to avatar image file of the project.' description: 'URL to avatar image file of the project.'
{
issues: "Issues are",
merge_requests: "Merge Requests are",
wiki: 'Wikis are',
snippets: 'Snippets are',
container_registry: 'Container Registry is'
}.each do |feature, name_string|
field "#{feature}_enabled", GraphQL::Types::Boolean, null: true,
description: "Indicates if #{name_string} enabled for the current user"
define_method "#{feature}_enabled" do
object.feature_available?(feature, context[:current_user])
end
end
field :jobs_enabled, GraphQL::Types::Boolean, null: true, field :jobs_enabled, GraphQL::Types::Boolean, null: true,
description: 'Indicates if CI/CD pipeline jobs are enabled for the current user.' description: 'Indicates if CI/CD pipeline jobs are enabled for the current user.'
...@@ -391,15 +375,6 @@ module Types ...@@ -391,15 +375,6 @@ module Types
null: true, null: true,
description: 'Template used to create squash commit message in merge requests.' description: 'Template used to create squash commit message in merge requests.'
def label(title:)
BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args|
LabelsFinder
.new(current_user, project: args[:key], title: titles)
.execute
.each { |label| loader.call(label.title, label) }
end
end
field :labels, field :labels,
Types::LabelType.connection_type, Types::LabelType.connection_type,
null: true, null: true,
...@@ -411,6 +386,32 @@ module Types ...@@ -411,6 +386,32 @@ module Types
description: 'Work item types available to the project.', description: 'Work item types available to the project.',
feature_flag: :work_items feature_flag: :work_items
def label(title:)
BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args|
LabelsFinder
.new(current_user, project: args[:key], title: titles)
.execute
.each { |label| loader.call(label.title, label) }
end
end
{
issues: "Issues are",
merge_requests: "Merge Requests are",
wiki: 'Wikis are',
snippets: 'Snippets are',
container_registry: 'Container Registry is'
}.each do |feature, name_string|
field "#{feature}_enabled", GraphQL::Types::Boolean, null: true,
description: "Indicates if #{name_string} enabled for the current user"
define_method "#{feature}_enabled" do
object.feature_available?(feature, context[:current_user])
end
end
markdown_field :description_html, null: true
def avatar_url def avatar_url
object.avatar_url(only_path: false) object.avatar_url(only_path: false)
end end
......
...@@ -14,11 +14,12 @@ module Types ...@@ -14,11 +14,12 @@ module Types
field :description, GraphQL::Types::String, null: true, field :description, GraphQL::Types::String, null: true,
description: 'Description of the topic.' description: 'Description of the topic.'
markdown_field :description_html, null: true
field :avatar_url, GraphQL::Types::String, null: true, field :avatar_url, GraphQL::Types::String, null: true,
description: 'URL to avatar image file of the topic.' description: 'URL to avatar image file of the topic.'
markdown_field :description_html, null: true
def avatar_url def avatar_url
object.avatar_url(only_path: false) object.avatar_url(only_path: false)
end end
......
...@@ -20,7 +20,6 @@ module Types ...@@ -20,7 +20,6 @@ module Types
authorize: :download_code authorize: :download_code
field :description, GraphQL::Types::String, null: true, field :description, GraphQL::Types::String, null: true,
description: 'Description (also known as "release notes") of the release.' description: 'Description (also known as "release notes") of the release.'
markdown_field :description_html, null: true
field :name, GraphQL::Types::String, null: true, field :name, GraphQL::Types::String, null: true,
description: 'Name of the release.' description: 'Name of the release.'
field :created_at, Types::TimeType, null: true, field :created_at, Types::TimeType, null: true,
...@@ -42,14 +41,16 @@ module Types ...@@ -42,14 +41,16 @@ module Types
field :author, Types::UserType, null: true, field :author, Types::UserType, null: true,
description: 'User that created the release.' description: 'User that created the release.'
def author
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, release.author_id).find
end
field :commit, Types::CommitType, null: true, field :commit, Types::CommitType, null: true,
complexity: 10, calls_gitaly: true, complexity: 10, calls_gitaly: true,
description: 'Commit associated with the release.' description: 'Commit associated with the release.'
markdown_field :description_html, null: true
def author
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, release.author_id).find
end
def commit def commit
return if release.sha.nil? return if release.sha.nil?
......
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