summaryrefslogtreecommitdiff
path: root/app/graphql
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/mutations/user_callouts/create.rb30
-rw-r--r--app/graphql/types/mutation_type.rb1
-rw-r--r--app/graphql/types/user_callout_feature_name_enum.rb12
-rw-r--r--app/graphql/types/user_callout_type.rb12
-rw-r--r--app/graphql/types/user_type.rb4
5 files changed, 59 insertions, 0 deletions
diff --git a/app/graphql/mutations/user_callouts/create.rb b/app/graphql/mutations/user_callouts/create.rb
new file mode 100644
index 00000000000..0d3dcacda41
--- /dev/null
+++ b/app/graphql/mutations/user_callouts/create.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Mutations
+ module UserCallouts
+ class Create < ::Mutations::BaseMutation
+ graphql_name 'UserCalloutCreate'
+
+ argument :feature_name,
+ GraphQL::STRING_TYPE,
+ required: true,
+ description: "The feature name you want to dismiss the callout for."
+
+ field :user_callout, Types::UserCalloutType,
+ null: false,
+ description: 'The user callout dismissed.'
+
+ def resolve(feature_name:)
+ callout = Users::DismissUserCalloutService.new(
+ container: nil, current_user: current_user, params: { feature_name: feature_name }
+ ).execute
+ errors = errors_on_object(callout)
+
+ {
+ user_callout: callout,
+ errors: errors
+ }
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index d1b168d0890..f0cc36f8b14 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -97,6 +97,7 @@ module Types
mount_mutation Mutations::Ci::Pipeline::Retry
mount_mutation Mutations::Ci::CiCdSettingsUpdate
mount_mutation Mutations::Namespace::PackageSettings::Update
+ mount_mutation Mutations::UserCallouts::Create
end
end
diff --git a/app/graphql/types/user_callout_feature_name_enum.rb b/app/graphql/types/user_callout_feature_name_enum.rb
new file mode 100644
index 00000000000..410ca5e1c95
--- /dev/null
+++ b/app/graphql/types/user_callout_feature_name_enum.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+module Types
+ class UserCalloutFeatureNameEnum < BaseEnum
+ graphql_name 'UserCalloutFeatureNameEnum'
+ description 'Name of the feature that the callout is for.'
+
+ ::UserCallout.feature_names.keys.each do |feature_name|
+ value feature_name.upcase, value: feature_name, description: "Callout feature name for #{feature_name}."
+ end
+ end
+end
diff --git a/app/graphql/types/user_callout_type.rb b/app/graphql/types/user_callout_type.rb
new file mode 100644
index 00000000000..12f4fdea878
--- /dev/null
+++ b/app/graphql/types/user_callout_type.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+module Types
+ class UserCalloutType < BaseObject # rubocop:disable Graphql/AuthorizeTypes
+ graphql_name 'UserCallout'
+
+ field :feature_name, UserCalloutFeatureNameEnum, null: false,
+ description: 'Name of the feature that the callout is for.'
+ field :dismissed_at, Types::TimeType, null: true,
+ description: 'Date when the callout was dismissed.'
+ end
+end
diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb
index 0cefc84633d..2cc7d379240 100644
--- a/app/graphql/types/user_type.rb
+++ b/app/graphql/types/user_type.rb
@@ -67,5 +67,9 @@ module Types
null: true,
description: 'Snippets authored by the user.',
resolver: Resolvers::Users::SnippetsResolver
+ field :callouts,
+ Types::UserCalloutType.connection_type,
+ null: true,
+ description: 'User callouts that belong to the user.'
end
end