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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
# frozen_string_literal: true
module Types
class QueryType < ::Types::BaseObject
graphql_name 'Query'
# The design management context object needs to implement #issue
DesignManagementObject = Struct.new(:issue)
field :board_list, ::Types::BoardListType,
null: true,
resolver: Resolvers::BoardListResolver
field :ci_application_settings, Types::Ci::ApplicationSettingType,
null: true,
description: 'CI related settings that apply to the entire instance.'
field :ci_config, resolver: Resolvers::Ci::ConfigResolver, complexity: 126 # AUTHENTICATED_MAX_COMPLEXITY / 2 + 1
field :ci_pipeline_stage, ::Types::Ci::StageType,
null: true, description: 'Stage belonging to a CI pipeline.' do
argument :id, type: ::Types::GlobalIDType[::Ci::Stage],
required: true, description: 'Global ID of the CI stage.'
end
field :ci_catalog_resources,
::Types::Ci::Catalog::ResourceType.connection_type,
null: true,
alpha: { milestone: '15.11' },
description: 'All CI/CD Catalog resources under a common namespace, visible to an authorized user',
resolver: ::Resolvers::Ci::Catalog::ResourcesResolver
field :ci_catalog_resource,
::Types::Ci::Catalog::ResourceType,
null: true,
alpha: { milestone: '16.1' },
description: 'A single CI/CD Catalog resource visible to an authorized user',
resolver: ::Resolvers::Ci::Catalog::ResourceResolver
field :ci_variables,
Types::Ci::InstanceVariableType.connection_type,
null: true,
description: "List of the instance's CI/CD variables.",
resolver: Resolvers::Ci::VariablesResolver
field :container_repository, Types::ContainerRepositoryDetailsType,
null: true,
description: 'Find a container repository.' do
argument :id,
type: ::Types::GlobalIDType[::ContainerRepository],
required: true,
description: 'Global ID of the container repository.'
end
field :current_user, Types::CurrentUserType,
null: true,
description: "Get information about current user."
field :design_management, Types::DesignManagementType,
null: false,
description: 'Fields related to design management.'
field :echo, resolver: Resolvers::EchoResolver
field :frecent_groups, [Types::GroupType],
resolver: Resolvers::Users::FrecentGroupsResolver,
description: "A user's frecently visited groups"
field :frecent_projects, [Types::ProjectType],
resolver: Resolvers::Users::FrecentProjectsResolver,
description: "A user's frecently visited projects"
field :gitpod_enabled, GraphQL::Types::Boolean,
null: true,
description: "Whether Gitpod is enabled in application settings."
field :group, Types::GroupType,
null: true,
resolver: Resolvers::GroupResolver,
description: "Find a group."
field :groups, Types::GroupType.connection_type,
null: true,
resolver: Resolvers::GroupsResolver,
description: "Find groups."
field :issue, Types::IssueType,
null: true,
description: 'Find an issue.' do
argument :id, ::Types::GlobalIDType[::Issue], required: true, description: 'Global ID of the issue.'
end
field :issues,
null: true,
alpha: { milestone: '15.6' },
resolver: Resolvers::IssuesResolver,
description: 'Find issues visible to the current user.' \
' At least one filter must be provided.'
field :jobs,
::Types::Ci::JobType.connection_type,
null: true,
description: 'All jobs on this GitLab instance.' \
' Returns an empty result for users without administrator access.',
resolver: ::Resolvers::Ci::AllJobsResolver
field :merge_request, Types::MergeRequestType,
null: true,
description: 'Find a merge request.' do
argument :id, ::Types::GlobalIDType[::MergeRequest], required: true, description: 'Global ID of the merge request.'
end
field :metadata, Types::MetadataType,
null: true,
resolver: Resolvers::MetadataResolver,
description: 'Metadata about GitLab.'
field :milestone, ::Types::MilestoneType,
null: true,
extras: [:lookahead],
description: 'Find a milestone.' do
argument :id, ::Types::GlobalIDType[Milestone], required: true, description: 'Find a milestone by its ID.'
end
field :namespace, Types::NamespaceType,
null: true,
resolver: Resolvers::NamespaceResolver,
description: "Find a namespace."
field :note,
::Types::Notes::NoteType,
null: true,
description: 'Find a note.',
alpha: { milestone: '15.9' } do
argument :id, ::Types::GlobalIDType[::Note],
required: true,
description: 'Global ID of the note.'
end
field :organization,
Types::Organizations::OrganizationType,
null: true,
resolver: Resolvers::Organizations::OrganizationResolver,
description: "Find an organization.",
alpha: { milestone: '16.4' }
field :organizations, Types::Organizations::OrganizationType.connection_type,
null: true,
resolver: Resolvers::Organizations::OrganizationsResolver,
description: "List organizations.",
alpha: { milestone: '16.8' }
field :package,
description: 'Find a package. This field can only be resolved for one query in any single request. Returns `null` if a package has no `default` status.',
resolver: Resolvers::PackageDetailsResolver
field :project, Types::ProjectType,
null: true,
resolver: Resolvers::ProjectResolver,
description: "Find a project."
field :projects,
null: true,
resolver: Resolvers::ProjectsResolver,
description: "Find projects visible to the current user."
field :query_complexity, Types::QueryComplexityType,
null: true,
description: 'Information about the complexity of the GraphQL query.'
field :runner, Types::Ci::RunnerType,
null: true,
resolver: Resolvers::Ci::RunnerResolver,
extras: [:lookahead],
description: "Find a runner."
field :runner_platforms, resolver: Resolvers::Ci::RunnerPlatformsResolver,
deprecated: { reason: 'No longer used, use gitlab-runner documentation to learn about supported platforms', milestone: '15.9' }
field :runner_setup, resolver: Resolvers::Ci::RunnerSetupResolver,
deprecated: { reason: 'No longer used, use gitlab-runner documentation to learn about runner registration commands', milestone: '15.9' }
field :runners, Types::Ci::RunnerType.connection_type,
null: true,
resolver: Resolvers::Ci::RunnersResolver,
description: "Get all runners in the GitLab instance (project and shared). " \
"Access is restricted to users with administrator access."
field :snippets,
Types::SnippetType.connection_type,
null: true,
resolver: Resolvers::SnippetsResolver,
description: 'Find Snippets visible to the current user.'
field :synthetic_note,
Types::Notes::NoteType,
null: true,
description: 'Find a synthetic note',
resolver: ::Resolvers::Notes::SyntheticNoteResolver,
alpha: { milestone: '15.9' }
field :timelogs, Types::TimelogType.connection_type,
null: true,
description: 'Find timelogs visible to the current user.',
extras: [:lookahead],
complexity: 5,
resolver: ::Resolvers::TimelogResolver
field :todo,
null: true,
resolver: Resolvers::TodoResolver
field :topics, Types::Projects::TopicType.connection_type,
null: true,
resolver: Resolvers::TopicsResolver,
description: "Find project topics."
field :usage_trends_measurements,
null: true,
description: 'Get statistics on the instance.',
resolver: Resolvers::Admin::Analytics::UsageTrends::MeasurementsResolver
field :user, Types::UserType,
null: true,
description: 'Find a user.',
resolver: Resolvers::UserResolver
field :users, Types::UserType.connection_type,
null: true,
description: 'Find users.',
resolver: Resolvers::UsersResolver
field :work_item, Types::WorkItemType,
null: true,
resolver: Resolvers::WorkItemResolver,
alpha: { milestone: '15.1' },
description: 'Find a work item.'
field :audit_event_definitions,
Types::AuditEvents::DefinitionType.connection_type,
null: false,
description: 'Definitions for all audit events available on the instance.',
resolver: Resolvers::AuditEvents::AuditEventDefinitionsResolver
field :abuse_report, ::Types::AbuseReportType,
null: true,
alpha: { milestone: '16.3' },
description: 'Find an abuse report.',
resolver: Resolvers::AbuseReportResolver
field :abuse_report_labels, ::Types::LabelType.connection_type,
null: true,
alpha: { milestone: '16.3' },
description: 'Abuse report labels.',
resolver: Resolvers::AbuseReportLabelsResolver
field :ml_model, ::Types::Ml::ModelType,
null: true,
alpha: { milestone: '16.7' },
description: 'Find machine learning models.',
resolver: Resolvers::Ml::ModelDetailResolver
field :work_items_by_reference,
null: true,
alpha: { milestone: '16.7' },
description: 'Find work items by their reference.',
extras: [:lookahead],
resolver: Resolvers::WorkItemReferencesResolver
def design_management
DesignManagementObject.new(nil)
end
def issue(id:)
GitlabSchema.find_by_gid(id)
end
def note(id:)
GitlabSchema.find_by_gid(id)
end
def merge_request(id:)
GitlabSchema.find_by_gid(id)
end
def milestone(id:, lookahead:)
preloads = [:releases] if lookahead.selects?(:releases)
Gitlab::Graphql::Loaders::BatchModelLoader.new(id.model_class, id.model_id, preloads).find
end
def container_repository(id:)
GitlabSchema.find_by_gid(id)
end
def current_user
context[:current_user]
end
def ci_application_settings
application_settings
end
def application_settings
Gitlab::CurrentSettings.current_application_settings
end
def gitpod_enabled
application_settings.gitpod_enabled
end
def query_complexity
context.query
end
def ci_pipeline_stage(id:)
stage = ::Gitlab::Graphql::Lazy.force(GitlabSchema.find_by_gid(id))
authorized = Ability.allowed?(current_user, :read_build, stage.project)
return unless authorized
stage
end
end
end
Types::QueryType.prepend_mod_with('Types::QueryType')
|