diff options
Diffstat (limited to 'app/graphql/resolvers/concerns/search_arguments.rb')
-rw-r--r-- | app/graphql/resolvers/concerns/search_arguments.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/graphql/resolvers/concerns/search_arguments.rb b/app/graphql/resolvers/concerns/search_arguments.rb new file mode 100644 index 00000000000..7f480f9d0b6 --- /dev/null +++ b/app/graphql/resolvers/concerns/search_arguments.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module SearchArguments + extend ActiveSupport::Concern + + included do + argument :search, GraphQL::Types::String, + required: false, + description: 'Search query for title or description.' + end + + def validate_anonymous_search_access! + return if current_user.present? || Feature.disabled?(:disable_anonymous_search, type: :ops) + + raise ::Gitlab::Graphql::Errors::ArgumentError, + "User must be authenticated to include the `search` argument." + end +end |