Skip to content

Commit

Permalink
Merge pull request #1534 from exogee-technology/fix/remove-set-in-dat…
Browse files Browse the repository at this point in the history
…aloader

Optimisation / Remove Set() in DataLoader
  • Loading branch information
thekevinbrown authored Jan 23, 2025
2 parents 1325ffa + a768b82 commit a9f4fe9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/packages/core/src/base-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ const getBaseLoadOneLoader = <G = unknown, D = unknown>({
}

const fetchRecordsById = async (keys: readonly string[]) => {
const uniqueKeys = [...new Set(keys)];

logger.trace(
`DataLoader: Loading ${gqlTypeName}, ${uniqueKeys.length} record(s): (${uniqueKeys.join(', ')})`
);
logger.trace({ keys }, `DataLoader: Loading ${gqlTypeName}, ${keys.length} record(s)`);
const primaryKeyField = graphweaverMetadata.primaryKeyFieldForEntity(entity) as keyof D;

let listFilter = {
[`${String(primaryKeyField)}_in`]: uniqueKeys,
[`${String(primaryKeyField)}_in`]: keys,
// Note: Typecast here shouldn't be necessary, but FilterEntity<G> doesn't like this.
} as Filter<G>;

Expand Down

0 comments on commit a9f4fe9

Please sign in to comment.