forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperiod.js
More file actions
52 lines (51 loc) · 1.65 KB
/
Copy pathperiod.js
File metadata and controls
52 lines (51 loc) · 1.65 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
import { GraphQLObjectType } from 'graphql'
import { categoryPercentagesType } from './category-percentages'
import { categoryTotalsType } from './category-totals'
import { detailTablesType } from './detail-tables'
import { PeriodEnums } from '../../enums'
import { Domain, Year } from '../../scalars'
export const periodType = new GraphQLObjectType({
name: 'Period',
description:
'Object that contains information for each data collection period.',
fields: () => ({
domain: {
type: Domain,
description: 'The domain that the data in this period belongs to.',
resolve: async (
{ domainKey },
_args,
{ loaders: { domainLoaderByKey } },
) => {
const domain = await domainLoaderByKey.load(domainKey)
return domain.domain
},
},
month: {
type: PeriodEnums,
description: 'Start date of data collection.',
resolve: ({ selectedMonth }) => selectedMonth,
},
year: {
type: Year,
description: 'End date of data collection.',
resolve: ({ startDate }, _, { moment }) =>
String(moment(startDate).year()),
},
categoryPercentages: {
type: categoryPercentagesType,
description: 'Category percentages based on the category totals.',
resolve: ({ categoryTotals }) => categoryTotals,
},
categoryTotals: {
type: categoryTotalsType,
description: 'Category totals for quick viewing.',
resolve: ({ categoryTotals }) => categoryTotals,
},
detailTables: {
type: detailTablesType,
description: 'Various senders for each category.',
resolve: ({ detailTables }) => detailTables,
},
}),
})