Skip to content

Commit

Permalink
Merge pull request #24 from CapgeminiInventUK/schools-resolver
Browse files Browse the repository at this point in the history
add la registered property to schools list
  • Loading branch information
JakeReadman authored Feb 9, 2024
2 parents c453052 + 1e2ff92 commit 7facfb6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/handlers/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,18 @@ export const handler: AppSyncResolverHandler<
const filteredSchools = schools.map((school) =>
removeFields<School>(info.selectionSetList, school)
);
callback(null, filteredSchools);
const localAuthorities = await localAuthorityDataRepository.list();
const filteredLas = localAuthorities.map((la) =>
removeFields<LocalAuthority>(info.selectionSetList, la)
);
const mappedSchools = filteredSchools.map((school) => {
const { localAuthority } = school;
const isLocalAuthorityRegistered = filteredLas.find(
({ name }) => name === localAuthority
)?.registered;
return { ...school, isLocalAuthorityRegistered };
});
callback(null, mappedSchools);
break;
}
case 'getLocalAuthorities': {
Expand Down

0 comments on commit 7facfb6

Please sign in to comment.