Skip to content

Commit

Permalink
refactor: remove duplicates when using deprecated resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Feb 13, 2024
1 parent 7f5c40c commit 008a75e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion services/api/src/resources/environment/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ export const deleteAllEnvironments: ResolverFn = async (
return 'success';
};

// @deprecated in favor of addOrUpdateEnvironmentService and deleteEnvironmentService, will eventually be removed
export const setEnvironmentServices: ResolverFn = async (
root,
{ input: { environment: environmentId, services } },
Expand All @@ -745,7 +746,11 @@ export const setEnvironmentServices: ResolverFn = async (

await query(sqlClientPool, Sql.deleteServices(environmentId));

for (const service of services) {
// remove any duplicates, since there is no other identifying information related to these duplicates don't matter.
// as this function is also being deprecated its usage over time will eventually drop
// this means removal of duplicates is an acceptable trade off while the transition takes place
var uniq = services.filter((value, index, array) => array.indexOf(value) === index);
for (const service of uniq) {
await query(sqlClientPool, Sql.insertService(environmentId, service));
}

Expand Down

0 comments on commit 008a75e

Please sign in to comment.