Skip to content

Commit 682140d

Browse files
committed
doc(module): add examples
1 parent e1d7026 commit 682140d

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

libs/graphile-worker/src/graphile-worker.module.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ export const GRAPHILE_WORKER_TOKEN = Symbol.for('NestJsGraphileWorker');
1515
export class GraphileWorkerModule {
1616
/**
1717
* Registers a globally available `GraphileWorkerService`.
18+
*
19+
* Example:
20+
*
21+
* ```ts
22+
* GraphileWorkerModule.forRoot({
23+
* connectionString: 'postgres://example:password@postgres/example',
24+
* taskList: {
25+
* hello: helloTask,
26+
* },
27+
* }),
28+
* ```
1829
*/
1930
static forRoot(config: GraphileWorkerConfiguration): DynamicModule {
2031
const graphileWorkerService: Provider = {
@@ -30,6 +41,24 @@ export class GraphileWorkerModule {
3041
};
3142
}
3243

44+
/**
45+
* Registers a globally available `GraphileWorkerService`.
46+
*
47+
* Example:
48+
*
49+
* ```ts
50+
* GraphileWorkerModule.forRootAsync({
51+
* imports: [ConfigModule],
52+
* inject: [ConfigService],
53+
* useFactory: (config: ConfigService) => ({
54+
* connectionString: config.get('PG_CONNECTION'),
55+
* taskList: {
56+
* hello: helloTask,
57+
* },
58+
* }),
59+
* }),
60+
* ```
61+
*/
3362
static forRootAsync(
3463
asyncConfig: GraphileWorkerAsyncConfiguration,
3564
): DynamicModule {

src/app.module.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { helloTask } from './hello.task';
66

77
@Module({
88
imports: [
9-
// GraphileWorkerModule.forRoot({
10-
// connectionString: 'postgres://example:password@postgres/example',
11-
// taskList: {
12-
// hello: helloTask,
13-
// },
14-
// }),
9+
GraphileWorkerModule.forRoot({
10+
connectionString: 'postgres://example:password@postgres/example',
11+
taskList: {
12+
hello: helloTask,
13+
},
14+
}),
1515
ConfigModule.forRoot(),
1616
GraphileWorkerModule.forRootAsync({
1717
imports: [ConfigModule],

0 commit comments

Comments
 (0)