forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdkim.js
More file actions
68 lines (65 loc) · 2.01 KB
/
Copy pathdkim.js
File metadata and controls
68 lines (65 loc) · 2.01 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
import { GraphQLInt, GraphQLObjectType, GraphQLString } from 'graphql'
import {
connectionArgs,
connectionDefinitions,
globalIdField,
} from 'graphql-relay'
import { domainType } from '../../domain/objects'
import { dkimResultConnection } from './dkim-result'
import { nodeInterface } from '../../node'
export const dkimType = new GraphQLObjectType({
name: 'DKIM',
fields: () => ({
id: globalIdField('dkim'),
domain: {
type: domainType,
description: `The domain the scan was ran on.`,
resolve: async ({ domainId }, _, { loaders: { domainLoaderByKey } }) => {
const domainKey = domainId.split('/')[1]
const domain = await domainLoaderByKey.load(domainKey)
domain.id = domain._key
return domain
},
},
timestamp: {
type: GraphQLString,
description: `The time when the scan was initiated.`,
resolve: ({ timestamp }) => timestamp,
},
results: {
type: dkimResultConnection.connectionType,
args: {
...connectionArgs,
},
description: 'Individual scans results for each dkim selector.',
resolve: async (
{ _id },
args,
{ loaders: { dkimResultsLoaderConnectionByDkimId } },
) => {
const dkimResults = await dkimResultsLoaderConnectionByDkimId({
dkimId: _id,
...args,
})
return dkimResults
},
},
}),
interfaces: [nodeInterface],
description: `DomainKeys Identified Mail (DKIM) permits a person, role, or
organization that owns the signing domain to claim some
responsibility for a message by associating the domain with the
message. This can be an author's organization, an operational relay,
or one of their agents.`,
})
export const dkimConnection = connectionDefinitions({
name: 'DKIM',
nodeType: dkimType,
connectionFields: () => ({
totalCount: {
type: GraphQLInt,
description: 'The total amount of dkim scans related to a given domain.',
resolve: ({ totalCount }) => totalCount,
},
}),
})