2016-10-10 18:37:26 +03:00
|
|
|
const PolicyType = require('../types/policy');
|
|
|
|
const graphql = require('graphql');
|
|
|
|
const api = require('../../api');
|
|
|
|
|
2017-04-27 21:26:15 +03:00
|
|
|
const { GraphQLList, GraphQLID } = graphql;
|
2016-10-10 18:37:26 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
type: new GraphQLList(PolicyType),
|
|
|
|
args: {
|
|
|
|
id: {
|
|
|
|
type: GraphQLID,
|
|
|
|
description: '`id` of the `PolicyType` to filter'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resolve(root, args) {
|
2017-04-27 21:26:15 +03:00
|
|
|
const { list, get } = api.policies;
|
2016-10-10 18:37:26 +03:00
|
|
|
|
2017-05-18 21:21:33 +03:00
|
|
|
return args.id ? get(args).then(policy => [policy]) : list();
|
2016-10-10 18:37:26 +03:00
|
|
|
}
|
|
|
|
};
|