Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_interface.rb « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5357f2f8e663838deba274792f4cedfa90b8ea3c (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
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
# frozen_string_literal: true

module Types
  module UserInterface
    include Types::BaseInterface

    graphql_name 'User'
    description 'Representation of a GitLab user.'

    field :user_permissions,
          type: Types::PermissionTypes::User,
          description: 'Permissions for the current user on the resource.',
          null: false,
          method: :itself

    field :id,
          type: GraphQL::Types::ID,
          null: false,
          description: 'ID of the user.'
    field :bot,
          type: GraphQL::Types::Boolean,
          null: false,
          description: 'Indicates if the user is a bot.',
          method: :bot?
    field :username,
          type: GraphQL::Types::String,
          null: false,
          description: 'Username of the user. Unique within this instance of GitLab.'
    field :name,
          type: GraphQL::Types::String,
          null: false,
          resolver_method: :redacted_name,
          description: 'Human-readable name of the user. ' \
          'Returns `****` if the user is a project bot and the requester does not have permission to view the project.'

    field :state,
          type: Types::UserStateEnum,
          null: false,
          description: 'State of the user.'
    field :email,
          type: GraphQL::Types::String,
          null: true,
          description: 'User email.', method: :public_email,
          deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' }
    field :emails,
          type: Types::Users::EmailType.connection_type,
          null: true,
          description: "User's email addresses."
    field :public_email,
          type: GraphQL::Types::String,
          null: true,
          description: "User's public email."
    field :commit_email,
          type: GraphQL::Types::String,
          null: true,
          description: "User's default commit email.",
          authorize: :read_user_email_address
    field :namespace_commit_emails,
          type: Types::Users::NamespaceCommitEmailType.connection_type,
          null: true,
          description: "User's custom namespace commit emails."
    field :avatar_url,
          type: GraphQL::Types::String,
          null: true,
          description: "URL of the user's avatar."
    field :web_url,
          type: GraphQL::Types::String,
          null: false,
          description: 'Web URL of the user.'
    field :web_path,
          type: GraphQL::Types::String,
          null: false,
          description: 'Web path of the user.'
    field :group_memberships,
          type: Types::GroupMemberType.connection_type,
          null: true,
          description: 'Group memberships of the user.'
    field :groups,
          resolver: Resolvers::Users::GroupsResolver,
          description: 'Groups where the user has access.'
    field :group_count,
          resolver: Resolvers::Users::GroupCountResolver,
          description: 'Group count for the user.'
    field :status,
          type: Types::UserStatusType,
          null: true,
          description: 'User status.'
    field :location,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'Location of the user.'
    field :project_memberships,
          type: Types::ProjectMemberType.connection_type,
          null: true,
          description: 'Project memberships of the user.'
    field :starred_projects,
          description: 'Projects starred by the user.',
          resolver: Resolvers::UserStarredProjectsResolver
    field :namespace,
          type: Types::NamespaceType,
          null: true,
          description: 'Personal namespace of the user.'

    field :todos,
          Types::TodoType.connection_type,
          description: 'To-do items of the user.',
          resolver: Resolvers::TodosResolver

    # Merge request field: MRs can be authored, assigned, or assigned-for-review:
    field :authored_merge_requests,
          resolver: Resolvers::AuthoredMergeRequestsResolver,
          description: 'Merge requests authored by the user.'
    field :assigned_merge_requests,
          resolver: Resolvers::AssignedMergeRequestsResolver,
          description: 'Merge requests assigned to the user.'
    field :review_requested_merge_requests,
          resolver: Resolvers::ReviewRequestedMergeRequestsResolver,
          description: 'Merge requests assigned to the user for review.'

    field :snippets,
          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.'
    field :timelogs,
          Types::TimelogType.connection_type,
          null: true,
          description: 'Time logged by the user.',
          extras: [:lookahead],
          complexity: 5,
          resolver: ::Resolvers::TimelogResolver
    field :saved_replies,
          Types::SavedReplyType.connection_type,
          null: true,
          description: 'Saved replies authored by the user. ' \
                       'Will not return saved replies if `saved_replies` feature flag is disabled.'

    field :saved_reply,
          resolver: Resolvers::SavedReplyResolver,
          description: 'Saved reply authored by the user. ' \
                       'Will not return saved reply if `saved_replies` feature flag is disabled.'

    field :gitpod_enabled, GraphQL::Types::Boolean, null: true,
                                                    description: 'Whether Gitpod is enabled at the user level.'

    field :preferences_gitpod_path,
          GraphQL::Types::String,
          null: true,
          description: 'Web path to the Gitpod section within user preferences.'

    field :profile_enable_gitpod_path, GraphQL::Types::String, null: true,
                                                               description: 'Web path to enable Gitpod for the user.'

    field :user_achievements,
          Types::Achievements::UserAchievementType.connection_type,
          null: true,
          alpha: { milestone: '15.10' },
          description: "Achievements for the user. " \
                       "Only returns for namespaces where the `achievements` feature flag is enabled.",
          extras: [:lookahead],
          resolver: ::Resolvers::Achievements::UserAchievementsResolver

    field :bio,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'Bio of the user.'

    field :linkedin,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'LinkedIn profile name of the user.'

    field :twitter,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'Twitter username of the user.'

    field :discord,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'Discord ID of the user.'

    field :organization,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'Who the user represents or works for.'

    field :job_title,
          type: ::GraphQL::Types::String,
          null: true,
          description: 'Job title of the user.'

    field :created_at,
          type: Types::TimeType,
          null: true,
          description: 'Timestamp of when the user was created.'

    definition_methods do
      def resolve_type(object, context)
        # in the absence of other information, we cannot tell - just default to
        # the core user type.
        ::Types::UserType
      end
    end

    def redacted_name
      object.redacted_name(context[:current_user])
    end
  end
end

Types::UserInterface.prepend_mod