Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds example with positional record #6806

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
```
Loading