Skip to content

Commit 42a8e94

Browse files
authored
Update DI part of readme (graphql-dotnet#4111)
1 parent a139531 commit 42a8e94

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,32 @@ For more information see [DataLoader](https://graphql-dotnet.github.io/docs/guid
121121
`DocumentExecuter` can handle subscriptions as well as queries and mutations.
122122
For more information see [Subscriptions](https://graphql-dotnet.github.io/docs/getting-started/subscriptions).
123123

124-
#### 6. Advanced Dependency Injection
124+
#### 6. Dependency Injection
125125

126-
Also we provide some extra classes for advanced dependency injection usage on top of
127-
`Microsoft.Extensions.DependencyInjection.Abstractions` package.
126+
To easily configure GraphQL.NET with the Microsoft dependency injection provider,
127+
you can use the `GraphQL.MicrosoftDI` package. This package provides a `AddGraphQL`
128+
extension method to register the necessary services. This package can also be used with
129+
other dependency injection providers that support the `Microsoft.Extensions.DependencyInjection`
130+
abstraction such as Autofac, Castle Windsor, and StructureMap.
128131

129132
```
130133
> dotnet add package GraphQL.MicrosoftDI
131134
```
132135

133-
For more information see [Thread safety with scoped services](https://graphql-dotnet.github.io/docs/getting-started/dependency-injection#thread-safety-with-scoped-services).
136+
You can then configure GraphQL.NET in your `Startup.cs` file like this:
137+
138+
```csharp
139+
public void ConfigureServices(IServiceCollection services)
140+
{
141+
services.AddGraphQL(b => b
142+
.AddSchema<MySchema>()
143+
.AddSystemTextJson()
144+
.AddDataLoader()
145+
);
146+
}
147+
```
148+
149+
For more information see [Dependency Injection](https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/).
134150

135151
## Examples
136152

0 commit comments

Comments
 (0)