-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathuser-personal.js
More file actions
90 lines (88 loc) · 3.13 KB
/
Copy pathuser-personal.js
File metadata and controls
90 lines (88 loc) · 3.13 KB
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
import { GraphQLBoolean, GraphQLObjectType, GraphQLString } from 'graphql'
import { connectionArgs, globalIdField } from 'graphql-relay'
import { GraphQLEmailAddress, GraphQLPhoneNumber } from 'graphql-scalars'
import { affiliationOrgOrder } from '../../affiliation/inputs'
import { affiliationConnection } from '../../affiliation/objects'
import { LanguageEnums, TfaSendMethodEnum } from '../../enums'
import { nodeInterface } from '../../node'
export const userPersonalType = new GraphQLObjectType({
name: 'PersonalUser',
fields: () => ({
id: globalIdField('user'),
userName: {
type: GraphQLEmailAddress,
description: 'Users email address.',
resolve: ({ userName }) => userName,
},
displayName: {
type: GraphQLString,
description: 'Name displayed to other users.',
resolve: ({ displayName }) => displayName,
},
phoneNumber: {
type: GraphQLPhoneNumber,
description: 'The phone number the user has setup with tfa.',
resolve: ({ phoneDetails }, _args, { validators: { decryptPhoneNumber } }) => {
if (typeof phoneDetails === 'undefined' || phoneDetails === null) {
return null
}
return decryptPhoneNumber(phoneDetails)
},
},
preferredLang: {
type: LanguageEnums,
description: 'Users preferred language.',
resolve: ({ preferredLang }) => preferredLang,
},
phoneValidated: {
type: GraphQLBoolean,
description: 'Has the user completed phone validation.',
resolve: ({ phoneValidated }) => phoneValidated,
},
emailValidated: {
type: GraphQLBoolean,
description: 'Has the user email verified their account.',
resolve: ({ emailValidated }) => emailValidated,
},
tfaSendMethod: {
type: TfaSendMethodEnum,
description: 'The method in which TFA codes are sent.',
resolve: ({ tfaSendMethod }) => tfaSendMethod,
},
insideUser: {
type: GraphQLBoolean,
description: 'Does the user want to see new features in progress.',
resolve: ({ insideUser }) => insideUser,
},
receiveUpdateEmails: {
type: GraphQLBoolean,
description: 'Does the user want to receive update emails.',
resolve: ({ receiveUpdateEmails }) => receiveUpdateEmails,
},
affiliations: {
type: affiliationConnection.connectionType,
description: 'Users affiliations to various organizations.',
args: {
orderBy: {
type: affiliationOrgOrder,
description: 'Ordering options for affiliation connections.',
},
search: {
type: GraphQLString,
description: 'String used to search for affiliated organizations.',
},
...connectionArgs,
},
resolve: async ({ _id }, args, { loaders: { loadAffiliationConnectionsByUserId } }) => {
const affiliations = await loadAffiliationConnectionsByUserId({
userId: _id,
...args,
})
return affiliations
},
},
}),
interfaces: [nodeInterface],
description: `This object is used for showing personal user details,
and is used for only showing the details of the querying user.`,
})