summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 08:17:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-18 08:17:02 +0000
commitb39512ed755239198a9c294b6a45e65c05900235 (patch)
treed234a3efade1de67c46b9e5a38ce813627726aa7 /app/graphql/resolvers
parentd31474cf3b17ece37939d20082b07f6657cc79a9 (diff)
downloadgitlab-ce-b39512ed755239198a9c294b6a45e65c05900235.tar.gz
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'app/graphql/resolvers')
-rw-r--r--app/graphql/resolvers/ci/config_resolver.rb4
-rw-r--r--app/graphql/resolvers/ci/runners_resolver.rb2
-rw-r--r--app/graphql/resolvers/ci/template_resolver.rb7
-rw-r--r--app/graphql/resolvers/crm/contact_state_counts_resolver.rb25
-rw-r--r--app/graphql/resolvers/crm/contacts_resolver.rb21
-rw-r--r--app/graphql/resolvers/environments_resolver.rb4
-rw-r--r--app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb2
-rw-r--r--app/graphql/resolvers/group_milestones_resolver.rb4
-rw-r--r--app/graphql/resolvers/projects/fork_targets_resolver.rb27
-rw-r--r--app/graphql/resolvers/projects_resolver.rb4
-rw-r--r--app/graphql/resolvers/users_resolver.rb2
-rw-r--r--app/graphql/resolvers/work_items_resolver.rb2
12 files changed, 91 insertions, 13 deletions
diff --git a/app/graphql/resolvers/ci/config_resolver.rb b/app/graphql/resolvers/ci/config_resolver.rb
index 1f486c47771..ec6ede58cf5 100644
--- a/app/graphql/resolvers/ci/config_resolver.rb
+++ b/app/graphql/resolvers/ci/config_resolver.rb
@@ -38,8 +38,8 @@ module Resolvers
.validate(content, dry_run: dry_run)
response(result)
- rescue GRPC::InvalidArgument => error
- Gitlab::ErrorTracking.track_and_raise_exception(error, sha: sha)
+ rescue GRPC::InvalidArgument => e
+ Gitlab::ErrorTracking.track_and_raise_exception(e, sha: sha)
end
private
diff --git a/app/graphql/resolvers/ci/runners_resolver.rb b/app/graphql/resolvers/ci/runners_resolver.rb
index 64738608b60..b52a4cc0ab4 100644
--- a/app/graphql/resolvers/ci/runners_resolver.rb
+++ b/app/graphql/resolvers/ci/runners_resolver.rb
@@ -36,7 +36,7 @@ module Resolvers
required: false,
description: 'Sort order of results.'
- argument :upgrade_status, ::Types::Ci::RunnerUpgradeStatusTypeEnum,
+ argument :upgrade_status, ::Types::Ci::RunnerUpgradeStatusEnum,
required: false,
description: 'Filter by upgrade status.'
diff --git a/app/graphql/resolvers/ci/template_resolver.rb b/app/graphql/resolvers/ci/template_resolver.rb
index 17f2668df11..f2531d877c7 100644
--- a/app/graphql/resolvers/ci/template_resolver.rb
+++ b/app/graphql/resolvers/ci/template_resolver.rb
@@ -5,8 +5,11 @@ module Resolvers
class TemplateResolver < BaseResolver
type Types::Ci::TemplateType, null: true
- argument :name, GraphQL::Types::String, required: true,
- description: 'Name of the CI/CD template to search for. Template must be formatted as `Name.gitlab-ci.yml`.'
+ argument :name,
+ GraphQL::Types::String,
+ required: true,
+ description: 'Name of the CI/CD template to search for. ' \
+ 'Template must be formatted as `Name.gitlab-ci.yml`.'
alias_method :project, :object
diff --git a/app/graphql/resolvers/crm/contact_state_counts_resolver.rb b/app/graphql/resolvers/crm/contact_state_counts_resolver.rb
new file mode 100644
index 00000000000..f696400d44e
--- /dev/null
+++ b/app/graphql/resolvers/crm/contact_state_counts_resolver.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Resolvers
+ module Crm
+ class ContactStateCountsResolver < BaseResolver
+ include Gitlab::Graphql::Authorize::AuthorizeResource
+
+ authorize :read_crm_contact
+
+ type Types::CustomerRelations::ContactStateCountsType, null: true
+
+ argument :search, GraphQL::Types::String,
+ required: false,
+ description: 'Search term to find contacts with.'
+
+ argument :state, Types::CustomerRelations::ContactStateEnum,
+ required: false,
+ description: 'State of the contacts to search for.'
+
+ def resolve(**args)
+ CustomerRelations::ContactStateCounts.new(context[:current_user], object, args)
+ end
+ end
+ end
+end
diff --git a/app/graphql/resolvers/crm/contacts_resolver.rb b/app/graphql/resolvers/crm/contacts_resolver.rb
index 58d0e2ce13d..a93942cf93b 100644
--- a/app/graphql/resolvers/crm/contacts_resolver.rb
+++ b/app/graphql/resolvers/crm/contacts_resolver.rb
@@ -10,6 +10,11 @@ module Resolvers
type Types::CustomerRelations::ContactType, null: true
+ argument :sort, Types::CustomerRelations::ContactSortEnum,
+ description: 'Criteria to sort contacts by.',
+ required: false,
+ default_value: { field: 'last_name', direction: :asc }
+
argument :search, GraphQL::Types::String,
required: false,
description: 'Search term to find contacts with.'
@@ -24,13 +29,25 @@ module Resolvers
def resolve(**args)
args[:ids] = resolve_ids(args.delete(:ids))
-
- ::Crm::ContactsFinder.new(current_user, { group: group }.merge(args)).execute
+ args.delete(:state) if args[:state] == :all
+
+ contacts = ::Crm::ContactsFinder.new(current_user, { group: group }.merge(args)).execute
+ if needs_offset?(args)
+ offset_pagination(contacts)
+ else
+ contacts
+ end
end
def group
object.respond_to?(:sync) ? object.sync : object
end
+
+ private
+
+ def needs_offset?(args)
+ args.key?(:sort) && args[:sort][:field] == 'organization'
+ end
end
end
end
diff --git a/app/graphql/resolvers/environments_resolver.rb b/app/graphql/resolvers/environments_resolver.rb
index 1823eb65d44..934c1ba2738 100644
--- a/app/graphql/resolvers/environments_resolver.rb
+++ b/app/graphql/resolvers/environments_resolver.rb
@@ -22,8 +22,8 @@ module Resolvers
return unless project.present?
Environments::EnvironmentsFinder.new(project, context[:current_user], args).execute
- rescue Environments::EnvironmentsFinder::InvalidStatesError => exception
- raise Gitlab::Graphql::Errors::ArgumentError, exception.message
+ rescue Environments::EnvironmentsFinder::InvalidStatesError => e
+ raise Gitlab::Graphql::Errors::ArgumentError, e.message
end
end
end
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 27bba6c8144..187063bb8c3 100644
--- a/app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb
+++ b/app/graphql/resolvers/error_tracking/sentry_detailed_error_resolver.rb
@@ -14,7 +14,7 @@ module Resolvers
response = ::ErrorTracking::IssueDetailsService.new(
project,
current_user,
- { issue_id: id.model_id }
+ { issue_id: id.model_id, tracking_event: :error_tracking_view_details }
).execute
issue = response[:issue]
issue.gitlab_project = project if issue
diff --git a/app/graphql/resolvers/group_milestones_resolver.rb b/app/graphql/resolvers/group_milestones_resolver.rb
index 319ff9f68c4..9242be7f684 100644
--- a/app/graphql/resolvers/group_milestones_resolver.rb
+++ b/app/graphql/resolvers/group_milestones_resolver.rb
@@ -45,5 +45,9 @@ module Resolvers
options: { include_subgroups: true }
).execute
end
+
+ def preloads
+ super.merge({ subgroup_milestone: :group })
+ end
end
end
diff --git a/app/graphql/resolvers/projects/fork_targets_resolver.rb b/app/graphql/resolvers/projects/fork_targets_resolver.rb
new file mode 100644
index 00000000000..5e8be325d43
--- /dev/null
+++ b/app/graphql/resolvers/projects/fork_targets_resolver.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Resolvers
+ module Projects
+ class ForkTargetsResolver < BaseResolver
+ include ResolvesGroups
+ include Gitlab::Graphql::Authorize::AuthorizeResource
+
+ type Types::NamespaceType.connection_type, null: true
+
+ authorize :fork_project
+ authorizes_object!
+
+ alias_method :project, :object
+
+ argument :search, GraphQL::Types::String,
+ required: false,
+ description: 'Search query for path or name.'
+
+ private
+
+ def resolve_groups(**args)
+ ForkTargetsFinder.new(project, current_user).execute(args)
+ end
+ end
+ end
+end
diff --git a/app/graphql/resolvers/projects_resolver.rb b/app/graphql/resolvers/projects_resolver.rb
index b846248458f..facf8ffe36f 100644
--- a/app/graphql/resolvers/projects_resolver.rb
+++ b/app/graphql/resolvers/projects_resolver.rb
@@ -25,8 +25,8 @@ module Resolvers
description: 'Sort order of results.'
argument :topics, type: [GraphQL::Types::String],
- required: false,
- description: 'Filters projects by topics.'
+ required: false,
+ description: 'Filters projects by topics.'
def resolve(**args)
ProjectsFinder
diff --git a/app/graphql/resolvers/users_resolver.rb b/app/graphql/resolvers/users_resolver.rb
index b0d704d09fc..90a6bd3e6b2 100644
--- a/app/graphql/resolvers/users_resolver.rb
+++ b/app/graphql/resolvers/users_resolver.rb
@@ -12,7 +12,7 @@ module Resolvers
description: 'List of user Global IDs.'
argument :usernames, [GraphQL::Types::String], required: false,
- description: 'List of usernames.'
+ description: 'List of usernames.'
argument :sort, Types::SortEnum,
description: 'Sort users by this criteria.',
diff --git a/app/graphql/resolvers/work_items_resolver.rb b/app/graphql/resolvers/work_items_resolver.rb
index 1bc74131b9e..055984db3cb 100644
--- a/app/graphql/resolvers/work_items_resolver.rb
+++ b/app/graphql/resolvers/work_items_resolver.rb
@@ -58,3 +58,5 @@ module Resolvers
end
end
end
+
+Resolvers::WorkItemsResolver.prepend_mod_with('Resolvers::WorkItemsResolver')