Skip to content

Commit df12f3c

Browse files
committed
fix: use own NotFoundError
1 parent 6bab8e9 commit df12f3c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/utilities/generateDataLoaderFactory.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ export default (
244244
245245
import {
246246
getByIds,
247-
getByIdsUsingJoiningTable
247+
getByIdsUsingJoiningTable,
248+
NotFoundError
248249
} from 'postloader';
249250
import DataLoader from 'dataloader';
250251
import type {
@@ -258,7 +259,7 @@ ${loaderTypes.map((body) => {
258259
}).sort().join(',\n')}
259260
|};
260261
261-
export const createLoaders = (connection: DatabaseConnectionType, NotFoundError: Class<Error>): LoadersType => {
262+
export const createLoaders = (connection: DatabaseConnectionType): LoadersType => {
262263
${loaders
263264
.map((body) => {
264265
return indent(body, 2);

test/postloader/utilities/generateDataLoaderFactory.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ test('creates a loader for unique indexes', (t) => {
3636
3737
import {
3838
getByIds,
39-
getByIdsUsingJoiningTable
39+
getByIdsUsingJoiningTable,
40+
NotFoundError
4041
} from 'postloader';
4142
import DataLoader from 'dataloader';
4243
import type {
@@ -55,7 +56,7 @@ export type LoadersType = {|
5556
+FooByBarLoader: DataLoader<string, FooRecordType>
5657
|};
5758
58-
export const createLoaders = (connection: DatabaseConnectionType, NotFoundError: Class<Error>): LoadersType => {
59+
export const createLoaders = (connection: DatabaseConnectionType): LoadersType => {
5960
const FooByBarLoader = new DataLoader((ids) => {
6061
return getByIds(connection, 'foo', ids, 'bar', '"bar"', false, NotFoundError);
6162
});
@@ -100,7 +101,8 @@ test('creates a loader for unique indexes (uses mappedTableName when available)'
100101
101102
import {
102103
getByIds,
103-
getByIdsUsingJoiningTable
104+
getByIdsUsingJoiningTable,
105+
NotFoundError
104106
} from 'postloader';
105107
import DataLoader from 'dataloader';
106108
import type {
@@ -119,7 +121,7 @@ export type LoadersType = {|
119121
+BazByBarLoader: DataLoader<string, BazRecordType>
120122
|};
121123
122-
export const createLoaders = (connection: DatabaseConnectionType, NotFoundError: Class<Error>): LoadersType => {
124+
export const createLoaders = (connection: DatabaseConnectionType): LoadersType => {
123125
const BazByBarLoader = new DataLoader((ids) => {
124126
return getByIds(connection, 'foo', ids, 'bar', '"bar"', false, NotFoundError);
125127
});
@@ -155,7 +157,8 @@ test('creates a loader for _id columns', (t) => {
155157
156158
import {
157159
getByIds,
158-
getByIdsUsingJoiningTable
160+
getByIdsUsingJoiningTable,
161+
NotFoundError
159162
} from 'postloader';
160163
import DataLoader from 'dataloader';
161164
import type {
@@ -174,7 +177,7 @@ export type LoadersType = {|
174177
+BazsByBarIdLoader: DataLoader<string, $ReadOnlyArray<BazRecordType>>
175178
|};
176179
177-
export const createLoaders = (connection: DatabaseConnectionType, NotFoundError: Class<Error>): LoadersType => {
180+
export const createLoaders = (connection: DatabaseConnectionType): LoadersType => {
178181
const BazsByBarIdLoader = new DataLoader((ids) => {
179182
return getByIds(connection, 'foo', ids, 'bar_id', '"bar_id" "barId"', true, NotFoundError);
180183
});
@@ -237,7 +240,8 @@ test('creates a loader for a join table', (t) => {
237240
238241
import {
239242
getByIds,
240-
getByIdsUsingJoiningTable
243+
getByIdsUsingJoiningTable,
244+
NotFoundError
241245
} from 'postloader';
242246
import DataLoader from 'dataloader';
243247
import type {
@@ -270,7 +274,7 @@ export type LoadersType = {|
270274
+FoosByBarIdLoader: DataLoader<string, $ReadOnlyArray<FooRecordType>>
271275
|};
272276
273-
export const createLoaders = (connection: DatabaseConnectionType, NotFoundError: Class<Error>): LoadersType => {
277+
export const createLoaders = (connection: DatabaseConnectionType): LoadersType => {
274278
const BarFoosByBarIdLoader = new DataLoader((ids) => {
275279
return getByIds(connection, 'bar_foo', ids, 'bar_id', '"bar_id" "barId", "foo_id" "fooId"', true, NotFoundError);
276280
});

0 commit comments

Comments
 (0)