Skip to content

Commit

Permalink
fix: ensures seed cache updates upon seed patch (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
samjcombs authored Dec 18, 2024
1 parent 3d08304 commit e710922
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion backend/src/routes/seeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,30 @@ router.patch('/seeds', async (req: Request, res: Response) => {
const {id, ...updateData} = req.body;
const seed = await DI.seeds.findOne({id});
if (!seed) return res.status(404).json({message: 'Seed not found'});

DI.seeds.assign(seed, updateData);
await DI.em.persistAndFlush(seed);

const mockServer = await getOrStartNewMockServer(
seed.graphId,
seed.variantName
);

mockServer?.seedManager.updateSeed(
seed.seedGroup.id.toString(),
seed.operationMatchArguments,
{
operationName: seed.operationName,
seedResponse: seed.seedResponse,
operationMatchArguments: seed.operationMatchArguments,
}
);

if (!mockServer) {
console.error('Could not start mock server');
return res.status(422).json({message: 'Could not start mock server'});
}

res.json({message: 'Seed updated successfully'});
});

export default router;

0 comments on commit e710922

Please sign in to comment.