From 21572c3a2ad4b452650ade9fb0532f718d3bad82 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 19 Feb 2019 04:03:05 +0100 Subject: [PATCH] Using default key --- src/schema/mutations/RegisterToEvent.js | 69 ++++++++++++++++--------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/src/schema/mutations/RegisterToEvent.js b/src/schema/mutations/RegisterToEvent.js index 8e28ba93f..3b0f6d1d6 100644 --- a/src/schema/mutations/RegisterToEvent.js +++ b/src/schema/mutations/RegisterToEvent.js @@ -58,18 +58,8 @@ const resolve = (parent, method: 'post', data: { query: ` - mutation { - operations_AddClone( - clone: { - botId: "${botId}" - botType: "Trading" - mode: "competition" - resumeExecution: false - runAsTeam: true - teamId: "${participantId}" - processName: "${event.title}-${participantId}" - } - ) { + { + keyVault_DefaultKey{ id } } @@ -77,18 +67,49 @@ const resolve = (parent, }, headers: { authorization }, }).then( - (operationCreation) => { - event.participants.push({ - participantId, - operationId: operationCreation.data.data.operations_AddClone.id, - }); - event.save((error) => { - if (error) { - rej(error); - return; - } - res(event); - }); + (keyResult) => { + axios({ + url: process.env.GATEWAY_ENDPOINT, + method: 'post', + data: { + query: ` + mutation { + operations_AddClone( + clone: { + botId: "${botId}" + botType: "Trading" + mode: "competition" + resumeExecution: false + runAsTeam: true + teamId: "${participantId}" + processName: "${event.title}-${participantId}" + keyId: "${keyResult.data.data.keyVault_DefaultKey.id}" + } + ) { + id + } + } + `, + }, + headers: { authorization }, + }).then( + (operationCreation) => { + event.participants.push({ + participantId, + operationId: operationCreation.data.data.operations_AddClone.id, + }); + event.save((error) => { + if (error) { + rej(error); + return; + } + res(event); + }); + }, + (error) => { + rej(new ServiceUnavailableError(error)); + }, + ); }, (error) => { rej(new ServiceUnavailableError(error));