joyent-portal/packages/cloudapi-gql/src/schema/queries/firewall-rules.js

20 lines
467 B
JavaScript

const FirewallRuleType = require('../types/firewall-rule');
const graphql = require('graphql');
const api = require('../../api');
const { GraphQLList, GraphQLID } = graphql;
module.exports = {
type: new GraphQLList(FirewallRuleType),
args: {
id: {
type: GraphQLID,
description: 'Filter on id'
}
},
resolve(root, args) {
const { list, get } = api.firewallRules;
return args.id ? get(args.id).then(rule => [rule]) : list();
}
};