blob: 8274b5cc49fbb2ef0f1db40ce0d6f2eeda2e6126 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# frozen_string_literal: true
module ResolvesSnippets
extend ActiveSupport::Concern
include ResolvesIds
included do
type Types::SnippetType.connection_type, null: true
argument :ids, [::Types::GlobalIDType[::Snippet]],
required: false,
description: 'Array of global snippet IDs. For example, `gid://gitlab/ProjectSnippet/1`.'
argument :visibility, Types::Snippets::VisibilityScopesEnum,
required: false,
description: 'Visibility of the snippet.'
end
def resolve(**args)
resolve_snippets(args)
end
private
def resolve_snippets(args)
SnippetsFinder.new(context[:current_user], snippet_finder_params(args)).execute
end
def snippet_finder_params(args)
{
ids: resolve_ids(args[:ids]),
scope: args[:visibility]
}.merge(options_by_type(args[:type]))
end
def options_by_type(type)
case type
when 'personal'
{ only_personal: true }
when 'project'
{ only_project: true }
else
{}
end
end
end
|