2019-12-10 02:53:40 -05:00
|
|
|
# frozen_string_literal: true
|
2020-11-17 07:09:15 -05:00
|
|
|
# rubocop:disable Graphql/ResolverType (inherited from ResolvesSnippets)
|
2019-12-10 02:53:40 -05:00
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module Projects
|
|
|
|
class SnippetsResolver < BaseResolver
|
|
|
|
include ResolvesSnippets
|
|
|
|
|
|
|
|
alias_method :project, :object
|
|
|
|
|
|
|
|
def resolve(**args)
|
|
|
|
return Snippet.none if project.nil?
|
|
|
|
|
2020-03-02 16:08:01 -05:00
|
|
|
unless project.feature_available?(:snippets, current_user)
|
|
|
|
raise Gitlab::Graphql::Errors::ResourceNotAvailable,
|
|
|
|
'Snippets are not enabled for this Project'
|
|
|
|
end
|
|
|
|
|
2019-12-10 02:53:40 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def snippet_finder_params(args)
|
|
|
|
super.merge(project: project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|