Simplifying input

This commit is contained in:
mati108@gmail.com committed 2019-02-09 14:59:10 -03:00
1 parent 767e910187
commit 0ddd35a460
3 files changed
+22 -29

No files matched your search

+21 -11
View File
@@ -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 -3
View File
@@ -1,7 +1,5 @@
import CloneInputType from './Clone'
import GetClonesInputType from './GetClones'
export {
CloneInputType,
GetClonesInputType
CloneInputType
};