joyent-portal/legacy/cloudapi-graphql/src/schema/queries/roles.js

21 lines
463 B
JavaScript
Raw Normal View History

2016-10-10 18:37:26 +03:00
const RoleType = require('../types/role');
const graphql = require('graphql');
const api = require('../../api');
const { GraphQLList, GraphQLID } = graphql;
2016-10-10 18:37:26 +03:00
module.exports = {
type: new GraphQLList(RoleType),
args: {
id: {
type: GraphQLID,
description: '`id` or `name` of the `RoleType` to filter'
}
},
resolve(root, args) {
const { list, get } = api.roles;
2016-10-10 18:37:26 +03:00
return !args.id ? list() : get(args).then(role => [role]);
2016-10-10 18:37:26 +03:00
}
};