Skip to content

Commit

Permalink
Move resolver section to top of migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-tengler committed Oct 23, 2021
1 parent f320234 commit 6bce5b2
Showing 1 changed file with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -52,23 +75,23 @@ 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]
}
```

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
}
```

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
}
Expand Down Expand Up @@ -132,15 +155,15 @@ Therefore we introduced two separate APIs to give you more explicit control over

## Global Object Identification

**OLD**
**v11**

```csharp
services
.AddGraphQLServer()
.EnableRelaySupport();
```

**NEW**
**v12**

```csharp
services
Expand All @@ -152,7 +175,7 @@ services

## Query field in Mutation payloads

**OLD**
**v11**

```csharp
services
Expand All @@ -165,7 +188,7 @@ services
});
```

**NEW**
**v12**

```csharp
sevices
Expand All @@ -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<string, string?>
Expand All @@ -205,7 +228,7 @@ public class CustomBatchDataLoader : BatchDataLoader<string, string?>
}
```

**Hot Chocolate 12**
**v12**

```csharp
public class CustomBatchDataLoader : BatchDataLoader<string, string?>
Expand All @@ -221,15 +244,3 @@ public class CustomBatchDataLoader : BatchDataLoader<string, string?>
```

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<string> MyResolver([Parent] Person parent, Person input)
{
// code omitted for brevity.
}
```

0 comments on commit 6bce5b2

Please sign in to comment.