forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind-my-domains.js
More file actions
49 lines (43 loc) · 1.23 KB
/
find-my-domains.js
File metadata and controls
49 lines (43 loc) · 1.23 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
import { GraphQLBoolean, GraphQLString } from 'graphql'
import { connectionArgs } from 'graphql-relay'
import { domainOrder } from '../inputs'
import { domainConnection } from '../objects'
export const findMyDomains = {
type: domainConnection.connectionType,
description: 'Select domains a user has access to.',
args: {
orderBy: {
type: domainOrder,
description: 'Ordering options for domain connections.',
},
ownership: {
type: GraphQLBoolean,
description:
'Limit domains to those that belong to an organization that has ownership.',
},
search: {
type: GraphQLString,
description: 'String used to search for domains.',
},
...connectionArgs,
},
resolve: async (
_,
args,
{
userKey,
auth: { checkSuperAdmin, userRequired, verifiedRequired },
loaders: { loadDomainConnectionsByUserId },
},
) => {
const user = await userRequired()
verifiedRequired({ user })
const isSuperAdmin = await checkSuperAdmin()
const domainConnections = await loadDomainConnectionsByUserId({
isSuperAdmin,
...args,
})
console.info(`User: ${userKey} successfully retrieved their domains.`)
return domainConnections
},
}