From 6bce5b2cd43a2ed3420462fc953d647cc8e0c0fa Mon Sep 17 00:00:00 2001 From: Tobias Tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Sat, 23 Oct 2021 10:16:16 +0200 Subject: [PATCH] Move resolver section to top of migration guide --- .../api-reference/migrate-from-11-to-12.md | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/website/src/docs/hotchocolate/api-reference/migrate-from-11-to-12.md b/website/src/docs/hotchocolate/api-reference/migrate-from-11-to-12.md index 98a075423bd..4991c2e837e 100644 --- a/website/src/docs/hotchocolate/api-reference/migrate-from-11-to-12.md +++ b/website/src/docs/hotchocolate/api-reference/migrate-from-11-to-12.md @@ -4,6 +4,29 @@ title: Migrate from Hot Chocolate GraphQL server 11 to 12 This guide will walk you through the manual migration steps to get your Hot Chocolate GraphQL server to version 12. +# Resolvers + +We have reworked the resolver compiler and are now demanding that the `ParentAttribute` is used when an argument is referring to the parent object. +This is done since in some cases people want to get the parent object which is the same runtime type as an argument value. + +**v11** + +```csharp +public string MyResolver(Person parent, string additionalInput) +{ + // Code omitted for brevity +} +``` + +**v12** + +```csharp +public string MyResolver([Parent] Person parent, string additionalInput) +{ + // Code omitted for brevity +} +``` + # Scalars We changed some defaults around scalars. These new defaults can break your existing schema but are, in general, better for newcomers and align better with the overall GraphQL ecosystem. Of course, you can naturally opt out of these new defaults to preserve your current schema's integrity. @@ -52,7 +75,7 @@ services We have changed the way we infer the name for the connection type when using cursor-based pagination. By default, the connection name is now inferred from the field name instead of the type name. -```SDL +```sdl type Person { friends: [Person] } @@ -60,7 +83,7 @@ type Person { In version 11, we would have created a connection named `PersonConnection`. -```SDL +```sdl type Person { friends(first: Int, last: Int, after: String, before: String): PersonConnection } @@ -68,7 +91,7 @@ type Person { In version 12, we now will infer the connection name as `FriendsConnection`. -```SDL +```sdl type Person { friends(first: Int, last: Int, after: String, before: String): FriendsConnection } @@ -132,7 +155,7 @@ Therefore we introduced two separate APIs to give you more explicit control over ## Global Object Identification -**OLD** +**v11** ```csharp services @@ -140,7 +163,7 @@ services .EnableRelaySupport(); ``` -**NEW** +**v12** ```csharp services @@ -152,7 +175,7 @@ services ## Query field in Mutation payloads -**OLD** +**v11** ```csharp services @@ -165,7 +188,7 @@ services }); ``` -**NEW** +**v12** ```csharp sevices @@ -190,7 +213,7 @@ We have consolidated the DataLoader base classes into the GreenDonut package whi Second, we optimized memory usage of DataLoader and it is now best practice to let the DI inject the DataLoaderOptions into the DataLoader. -**Hot Chocolate 11** +**v11** ```csharp public class CustomBatchDataLoader : BatchDataLoader @@ -205,7 +228,7 @@ public class CustomBatchDataLoader : BatchDataLoader } ``` -**Hot Chocolate 12** +**v12** ```csharp public class CustomBatchDataLoader : BatchDataLoader @@ -221,15 +244,3 @@ public class CustomBatchDataLoader : BatchDataLoader ``` Allowing the DI to inject the options will allow the DataLoader to use the new shared pooled cache objects. - -# Resolvers - -We have reworked the resolver compiler and are now demanding that the `ParentAttribute` is used when an argument is referring to the parent object. -This is done since in some cases people want to get the parent object which is the same runtime type as an argument value. - -```csharp -public async Task MyResolver([Parent] Person parent, Person input) -{ - // code omitted for brevity. -} -```