Adding base version for Operations Module
This commit is contained in:
1 parent
ae08794750
commit
d397c87d68
64 files changed
+3524
-1
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
|
||||
import {
|
||||
AuthentificationError,
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
import removeKuberneteClone from '../../kubernetes/removeClone'
|
||||
//import saveAuditLog from './AddAuditLog'
|
||||
|
||||
const args = {
|
||||
id: {type: new GraphQLNonNull(GraphQLID)}
|
||||
}
|
||||
|
||||
const resolve = async (parent, { id }, context) => {
|
||||
logger.debug('removeClone -> Entering Fuction.')
|
||||
|
||||
if (!context.userId) {
|
||||
throw new AuthentificationError()
|
||||
}
|
||||
|
||||
await removeKuberneteClone(id)
|
||||
|
||||
var query = {
|
||||
_id: id,
|
||||
authId: context.userId
|
||||
}
|
||||
|
||||
//saveAuditLog(id, 'removeClone', context)
|
||||
logger.debug('removeClone -> Removing Clone from DB.')
|
||||
Clone.deleteOne(query, function (err) {
|
||||
if (err){
|
||||
throw new OperationsError(err)
|
||||
}else{
|
||||
return 'Clone Removed'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
removeClone: {
|
||||
type: GraphQLString,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
Reference in new issue
Block a user