forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmx-record.js
More file actions
57 lines (54 loc) · 1.59 KB
/
Copy pathmx-record.js
File metadata and controls
57 lines (54 loc) · 1.59 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
import { GraphQLInt, GraphQLList, GraphQLObjectType, GraphQLString } from 'graphql'
import { GraphQLDateTime } from 'graphql-scalars'
import { globalIdField } from 'graphql-relay'
export const mxHostType = new GraphQLObjectType({
name: 'MXHost',
fields: () => ({
preference: {
type: GraphQLInt,
description: `The preference (or priority) of the host.`,
},
hostname: {
type: GraphQLString,
description: `The hostname of the given host.`,
},
addresses: {
type: new GraphQLList(GraphQLString),
description: `The IP addresses for the given host.`,
},
}),
description: `Hosts listed in the domain's MX record.`,
})
export const mxRecordType = new GraphQLObjectType({
name: 'MXRecord',
fields: () => ({
hosts: {
type: new GraphQLList(mxHostType),
description: `Hosts listed in the domain's MX record.`,
},
warnings: {
type: new GraphQLList(GraphQLString),
description: `Additional warning info about the MX record.`,
},
error: {
type: GraphQLString,
description: `Error message if the MX record could not be retrieved.`,
},
}),
})
export const mxRecordDiffType = new GraphQLObjectType({
name: 'MXRecordDiff',
fields: () => ({
id: globalIdField('dns'),
timestamp: {
type: GraphQLDateTime,
description: `The time when the scan was initiated.`,
resolve: ({ timestamp }) => new Date(timestamp),
},
mxRecords: {
type: mxRecordType,
description: `The MX records for the domain (if they exist).`,
resolve: ({ mxRecords }) => mxRecords,
},
}),
})