Skip to content

Commit 8a35833

Browse files
authored
correct DataLoader import
Using '''typescript import DataLoader from 'dataloader' ''' leads to the error: "TypeError: dataloader_1.default is not a constructor" at the point where the generateDataLoader function is called. changing to '''typescript import * DataLoader from 'dataloader' ''' fixes this issue
1 parent edf462d commit 8a35833

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ npm install --save nestjs-dataloader
1818
We start by implementing the ```NestDataLoader``` interface. This tells ```DataLoader``` how to load our objects.
1919

2020
``` typescript
21-
import DataLoader from 'dataloader';
21+
import * as DataLoader from 'dataloader';
2222
import { Injectable } from '@nestjs/common';
2323
import { NestDataLoader } from 'nestjs-dataloader';
2424
...
@@ -61,7 +61,7 @@ export class ResolversModule { }
6161
### Using the NestDataLoader
6262
Now that we have a dataloader and our module is aware of it, we need to pass it as a parameter to an endpoint in our graphQL resolver.
6363
``` typescript
64-
import DataLoader from 'dataloader';
64+
import * as DataLoader from 'dataloader';
6565
import { Loader } from 'nestjs-dataloader';
6666
...
6767

@@ -78,4 +78,4 @@ export class AccountResolver {
7878
```
7979
The important thing to note is that the parameter of the ```@Loader``` decorator is the name of the ```NestDataLoader``` class we want to be injected to the method. The DataLoader library will handle bulk retrieval and caching of our requests. Note that the caching is stored on a per-request basis.
8080
## Contributing
81-
Pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.
81+
Pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.

0 commit comments

Comments
 (0)