@wepublish/api
Version:
API core for we.publish.
69 lines • 3.17 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLUserRoleSort = exports.GraphQLUserRoleFilter = exports.GraphQLUserRoleInput = exports.GraphQLUserRoleConnection = exports.GraphQLUserRole = exports.GraphQLPermission = void 0;
const graphql_1 = require("graphql");
const api_1 = require("../../../permissions-api/src");
const common_1 = require("./common");
const userRole_1 = require("../db/userRole");
exports.GraphQLPermission = new graphql_1.GraphQLObjectType({
name: 'Permission',
fields: {
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
description: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
deprecated: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) }
}
});
exports.GraphQLUserRole = new graphql_1.GraphQLObjectType({
name: 'UserRole',
fields: {
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
description: { type: graphql_1.GraphQLString },
systemRole: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
permissions: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLPermission))),
resolve({ id, permissionIDs }) {
switch (id) {
case 'admin':
return api_1.AllPermissions;
case 'editor':
return api_1.EditorPermissions;
case 'peer':
return api_1.PeerPermissions;
default:
return api_1.AllPermissions.filter(permission => permissionIDs.includes(permission.id));
}
}
}
}
});
exports.GraphQLUserRoleConnection = new graphql_1.GraphQLObjectType({
name: 'UserRoleConnection',
fields: {
nodes: { type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLUserRole))) },
pageInfo: { type: new graphql_1.GraphQLNonNull(common_1.GraphQLPageInfo) },
totalCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) }
}
});
exports.GraphQLUserRoleInput = new graphql_1.GraphQLInputObjectType({
name: 'UserRoleInput',
fields: {
name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
description: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
permissionIDs: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)) }
}
});
exports.GraphQLUserRoleFilter = new graphql_1.GraphQLInputObjectType({
name: 'UserRoleFilter',
fields: {
name: { type: graphql_1.GraphQLString }
}
});
exports.GraphQLUserRoleSort = new graphql_1.GraphQLEnumType({
name: 'UserRoleSort',
values: {
CREATED_AT: { value: userRole_1.UserRoleSort.CreatedAt },
MODIFIED_AT: { value: userRole_1.UserRoleSort.ModifiedAt }
}
});
//# sourceMappingURL=userRole.js.map