Skip to content

Commit

Permalink
docs(container): add InversifyJS side note (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
evandroabukamel authored and MichalLytek committed Oct 20, 2019
1 parent 7298199 commit 98e9839
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions docs/dependency-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ TypeGraphQL supports this technique by allowing users to provide their IoC conta

## Basic usage

The usage of this feature is very simple - all you need to do is register a 3rd party container. Example using TypeDI:
The usage of this feature is very simple - all you need to do is register a 3rd party container.

Example using TypeDI:

```typescript
import { buildSchema } from "type-graphql";
Expand Down Expand Up @@ -66,9 +68,14 @@ export class RecipeService {
}
```

### Example

You can see how this fits together in the [simple example](https://github.com/MichalLytek/type-graphql/tree/master/examples/using-container).
> Be aware than when you use [InversifyJS](https://github.com/inversify/InversifyJS), you have to bind the resolver class with the [self-binding of concrete types](https://github.com/inversify/InversifyJS/blob/master/wiki/classes_as_id.md#self-binding-of-concrete-types), e.g.:
>
> ```typescript
> container
> .bind<SampleResolver>(SampleResolver)
> .to(SampleResolver)
> .inSingletonScope();
> ```
## Scoped containers
Expand Down Expand Up @@ -141,6 +148,8 @@ The only thing that's left is the container configuration - we need to check out
> Be aware that some libraries (like `TypeDI`) by default create new instances for every scoped container, so you might experience a **significant increase in memory usage** and some slowing down in query resolving speed, so please be careful with using this feature!
### Example
## Example
You can see how this fits together in the [simple example](https://github.com/MichalLytek/type-graphql/tree/master/examples/using-container).
For a more advanced usage example with scoped containers, check out [advanced example with scoped containers](https://github.com/MichalLytek/type-graphql/tree/master/examples/using-scoped-container).

0 comments on commit 98e9839

Please sign in to comment.