Simplifying input
This commit is contained in:
1 parent
767e910187
commit
0ddd35a460
3 files changed
+22
-29
No files matched your search
@@ -7,31 +7,41 @@ import {
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
|
||||
import { GetClonesInputType } from '../types/input';
|
||||
import { GetClonesType } from '../types'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
|
||||
import mongoose from 'mongoose'
|
||||
import { isDefined } from '../../config/utils'
|
||||
|
||||
const args = {
|
||||
cloneIdList: {type: GetClonesInputType}
|
||||
cloneIdList: { type: new GraphQLList(GraphQLID) }
|
||||
}
|
||||
|
||||
const resolve = async(parent, { cloneIdList }, context) => {
|
||||
logger.debug('Get Clones -> Entering Fuction. %j', cloneIdList)
|
||||
try{
|
||||
let clones = []
|
||||
for (var i = 0; i < cloneIdList.cloneIdList.length; i++) {
|
||||
let existingClone = await Clone.findOne({
|
||||
_id: cloneIdList.cloneIdList[i]
|
||||
})
|
||||
for (var i = 0; i < cloneIdList.length; i++) {
|
||||
|
||||
if(isDefined(existingClone)){
|
||||
if(mongoose.Types.ObjectId.isValid(cloneIdList[i])){
|
||||
let existingClone = await Clone.findOne({
|
||||
_id: cloneIdList[i]
|
||||
})
|
||||
|
||||
if(isDefined(existingClone)){
|
||||
clones.push({
|
||||
id: cloneIdList[i],
|
||||
teamId: existingClone.teamId,
|
||||
botId: existingClone.botId
|
||||
})
|
||||
}else{
|
||||
clones.push({
|
||||
id: cloneIdList[i]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
clones.push({
|
||||
id: cloneIdList.cloneIdList[i],
|
||||
teamId: existingClone.teamId,
|
||||
botId: existingClone.botId
|
||||
id: cloneIdList[i]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import {
|
||||
GraphQLInputObjectType,
|
||||
GraphQLList,
|
||||
GraphQLID
|
||||
} from 'graphql';
|
||||
|
||||
const Type = new GraphQLInputObjectType({
|
||||
name: 'GetClonesInput',
|
||||
description: 'Allows to receive a list of clone ids to get information',
|
||||
fields: () => ({
|
||||
cloneIdList: { type: new GraphQLList(GraphQLID) }
|
||||
})
|
||||
});
|
||||
|
||||
export default Type;
|
||||
@@ -1,7 +1,5 @@
|
||||
import CloneInputType from './Clone'
|
||||
import GetClonesInputType from './GetClones'
|
||||
|
||||
export {
|
||||
CloneInputType,
|
||||
GetClonesInputType
|
||||
CloneInputType
|
||||
};
|
||||
Reference in new issue
Block a user