create new mission validation and action

This commit is contained in:
Eng. Elias
2024-02-29 14:30:48 +04:00
parent 7dec195a78
commit 61fabd883f
10 changed files with 112 additions and 38 deletions

View File

@@ -54,12 +54,18 @@ const resolvers = {
in: body.crew,
},
},
select: {
id: true,
},
});
const tasks = [];
for (let task of body.tasks) {
const agent = await prisma.agent.findFirst({
where: { id: task.agent },
});
let agent = null;
if (task.agent) {
agent = await prisma.agent.findFirst({
where: { id: task.agent },
});
}
tasks.push({
...task,
agent,
@@ -70,12 +76,11 @@ const resolvers = {
name,
verbose: !!verbose,
process: process ?? Process.SEQUENTIAL,
crew: { create: crew },
crew: { connect: crew },
tasks,
result: "",
},
});
mission.id;
return mission;
},
updateMission: async (parent, body, context, info) => {
@@ -90,9 +95,12 @@ const resolvers = {
const tasks = [];
if (body.tasks) {
for (let task of body.tasks) {
const agent = await prisma.agent.findFirst({
where: { id: task.agent },
});
let agent = null;
if (task.agent) {
agent = await prisma.agent.findFirst({
where: { id: task.agent },
});
}
tasks.push({
...task,
agent,

View File

@@ -31,7 +31,7 @@ const typeDefs = `#graphql
type Task {
name: String!
description: String!
agent: Agent!
agent: Agent
}
input TaskInput {