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

21 lines
462 B
JavaScript

const RoleType = require('../types/role');
const graphql = require('graphql');
const api = require('../../api');
const { GraphQLList, GraphQLID } = graphql;
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;
return args.id ? get(args).then(role => [role]) : list();
}
};