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

20 lines
401 B
JavaScript
Raw Normal View History

2016-10-10 18:37:26 +03:00
const NicType = require('../types/nic');
const graphql = require('graphql');
const api = require('../../api');
const { GraphQLList, GraphQLString } = graphql;
2016-10-10 18:37:26 +03:00
module.exports = {
type: new GraphQLList(NicType),
args: {
mac: {
type: GraphQLString
}
},
resolve(root, args) {
const { list, get } = api.nics;
2016-10-10 18:37:26 +03:00
return !args.id ? list() : get(args).then(nic => [nic]);
2016-10-10 18:37:26 +03:00
}
};