Skip to content

Commit 46b40ca

Browse files
committed
Update docs
1 parent 0895299 commit 46b40ca

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

docs/introduction/configuration.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ import { MyProvider } from './my-provider.ts';
1515
export interface MyModuleConfig {
1616
secretKey: string;
1717
remoteEndpoint: string;
18+
someDbInstance: SomeDBInstance;
1819
}
1920

21+
// You can access config object like below inside module declaration
2022
export const MyModule = new GraphQLModule<MyModuleConfig>({
21-
providers: () => [
22-
MyProvider
23+
providers: ({ config: { someDbInstance } }) => [
24+
MyProvider,
25+
{
26+
provide: SomeDbInstance,
27+
useValue: someDbInstance
28+
}
2329
]
2430
});
2531
```

docs/introduction/test-your-module.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,19 @@ tests/user.module.spec.ts
8282
});
8383
```
8484

85+
If you don't use DI, you can mock your context or resolvers like below;
86+
87+
```ts
88+
UsersModule.mock({
89+
resolvers: {
90+
Query: {
91+
foo: (_, __, { fooProp }) => fooProp
92+
}
93+
},
94+
contextBuilder: () => ({
95+
fooProp: 'FOO'
96+
})
97+
})
98+
```
99+
85100
Then, run `jest` to get your test results.

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ module.exports = {
1010
testRegex: '\\.spec\\.ts$',
1111
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
1212
errorOnDeprecated: true,
13+
forceExit: true,
1314
};

0 commit comments

Comments
 (0)