v12.0.0 - initial commit
This commit is contained in:
commit
e2c49ea43c
1145 changed files with 97211 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
const DataLoader = require('dataloader')
|
||||
|
||||
const {
|
||||
getAllMachineGroups,
|
||||
createMachineGroup,
|
||||
deleteMachineGroup,
|
||||
assignComplianceTriggerSetToMachineGroup,
|
||||
} = require('../../services/machineGroups')
|
||||
|
||||
const {
|
||||
getComplianceTriggerSetsByIdsBatch,
|
||||
} = require('../../services/triggers')
|
||||
|
||||
const complianceTriggerSetsLoader = new DataLoader(
|
||||
ids => getComplianceTriggerSetsByIdsBatch(ids),
|
||||
{ cache: false },
|
||||
)
|
||||
|
||||
const resolvers = {
|
||||
MachineGroup: {
|
||||
complianceTriggerSet: parent =>
|
||||
parent.complianceTriggerSetId
|
||||
? complianceTriggerSetsLoader.load(parent.complianceTriggerSetId)
|
||||
: null,
|
||||
},
|
||||
Query: {
|
||||
machineGroups: () => getAllMachineGroups(),
|
||||
},
|
||||
Mutation: {
|
||||
createMachineGroup: (...[, { name }]) => createMachineGroup(name),
|
||||
deleteMachineGroup: (...[, { id }]) => deleteMachineGroup(id),
|
||||
assignComplianceTriggerSetToMachineGroup: (
|
||||
source,
|
||||
{ id, complianceTriggerSetId },
|
||||
) => assignComplianceTriggerSetToMachineGroup(id, complianceTriggerSetId),
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = resolvers
|
||||
Loading…
Add table
Add a link
Reference in a new issue