forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-personal.js
More file actions
99 lines (97 loc) · 3.61 KB
/
Copy pathuser-personal.js
File metadata and controls
99 lines (97 loc) · 3.61 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
91
92
93
94
95
96
97
98
99
import { GraphQLBoolean, GraphQLList, 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 { TfaSendMethodEnum } from '../../enums'
import { nodeInterface } from '../../node'
import { emailUpdateOptionsType } from './email-update-options'
import { dismissedMessage } from './dismissed-message'
import { completedTour } from './completed-tour'
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)
},
},
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,
},
emailUpdateOptions: {
type: emailUpdateOptionsType,
description:
'A number of different emails the user can optionally receive periodically that provide updates about their organization.',
resolve: ({ emailUpdateOptions }) => emailUpdateOptions,
},
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
},
},
dismissedMessages: {
type: new GraphQLList(dismissedMessage),
description: 'Messages that the user has dismissed.',
resolve: ({ dismissedMessages }) => dismissedMessages || [],
},
completedTours: {
type: new GraphQLList(completedTour),
description: 'Tours the user has completed.',
resolve: ({ completedTours }) => completedTours || [],
},
}),
interfaces: [nodeInterface],
description: `This object is used for showing personal user details,
and is used for only showing the details of the querying user.`,
})