Skip to content

Commit aa80b4a

Browse files
authored
Added migration sections for Dependency Injection and Entity Framework (#7634)
1 parent eb2a553 commit aa80b4a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

website/src/docs/hotchocolate/v14/migrating/migrate-from-13-to-14.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,42 @@ Things that have been removed or had a change in behavior that may cause your co
4444
| @chillicream/bananacakepop-express-middleware | @chillicream/nitro-express-middleware | |
4545
| @chillicream/bananacakepop-graphql-ide | @chillicream/nitro-embedded | `mode: "self"` is now `mode: "embedded"` |
4646

47+
## Dependency injection changes
48+
49+
- It is no longer necessary to use the `[Service]` attribute unless you're using keyed services, in which case the attribute is used to specify the key.
50+
- Hot Chocolate will identify services automatically.
51+
- Support for the `[FromServices]` attribute has been removed.
52+
- As with the `[Service]` attribute above, this attribute is no longer necessary.
53+
- Since the `RegisterService` method is no longer required, it has been removed, along with the `ServiceKind` enum.
54+
- Scoped services injected into query resolvers are now resolver-scoped by default (not request scoped). For mutation resolvers, services are request-scoped by default.
55+
- The default scope can be changed in two ways:
56+
57+
1. Globally, using `ModifyOptions`:
58+
59+
```csharp
60+
builder.Services
61+
.AddGraphQLServer()
62+
.ModifyOptions(o =>
63+
{
64+
o.DefaultQueryDependencyInjectionScope =
65+
DependencyInjectionScope.Resolver;
66+
o.DefaultMutationDependencyInjectionScope =
67+
DependencyInjectionScope.Request;
68+
});
69+
```
70+
71+
2. On a per-resolver basis, with the `[UseRequestScope]` or `[UseResolverScope]` attribute.
72+
- Note: The `[UseServiceScope]` attribute has been removed.
73+
74+
For more information, see the [Dependency Injection](/docs/hotchocolate/v14/server/dependency-injection) documentation.
75+
76+
## Entity framework integration changes
77+
78+
- The `RegisterDbContext` method is no longer required, and has therefore been removed, along with the `DbContextKind` enum.
79+
- Use `RegisterDbContextFactory` to register a DbContext factory.
80+
81+
For more information, see the [Entity Framework integration](/docs/hotchocolate/v14/integrations/entity-framework) documentation.
82+
4783
## New GID format
4884

4985
This release introduces a more performant GID serializer, which also simplifies the underlying format of globally unique IDs.

0 commit comments

Comments
 (0)