Skip to content

Commit

Permalink
Adds example with positional record
Browse files Browse the repository at this point in the history
  • Loading branch information
tsinghammer committed Jan 7, 2024
1 parent f586c51 commit c181a0c
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,23 @@ query {
}
}
```

## C# Records
Records can be decorated almost in the same way as classes to add Apollo Federation support.
The above Product example as a positional record would look like this:

```csharp
public record Product([property: ID][property: Key] string Id, string Name, float Price)
{
[ReferenceResolver]
public static async Task<Product?> ResolveReference(
// Represents the value that would be in the Id property of a Product
string id,
// Example of a service that can resolve the Products
ProductBatchDataLoader dataLoader
)
{
return await dataloader.LoadAsync(id);
}
}
```

0 comments on commit c181a0c

Please sign in to comment.