Skip to content
Open
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions website/src/docs/fusion/v16/data-requirements-and-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ type Product {
}
```

**C# resolver**

```csharp
[ObjectType<Product>]
public static partial class ProductNode
{
public static decimal GetTaxEstimate(
[Parent] Product product,
[Require("seller.address.countryCode")] string countryCode,
[Require] float price)
=> TaxCalculator.Estimate(countryCode, price);
Comment on lines +224 to +228
}
```

The gateway traverses `seller.address.countryCode` on the entity and passes the resolved value as the `countryCode` argument.

### List Aggregation Paths
Expand All @@ -235,6 +249,29 @@ type Product {

The path `seller.addresses[countryCode]` means: navigate to `seller.addresses` (a list), then select `countryCode` from each element. If the seller has three addresses with country codes `"US"`, `"DE"`, and `"US"`, the resolver receives `["US", "DE", "US"]` as the `countryCodes` argument.

**C# resolver**

```csharp
[ObjectType<Product>]
public static partial class ProductNode
{
public static decimal GetTaxEstimate(
[Parent] Product product,
[Require("seller.addresses[countryCode]")] string[] countryCodes,
[Require] float price)
=> TaxCalculator.Estimate(countryCodes, price);
Comment on lines +258 to +262
}
```

For the list projection variant (`dimensions[{ weight, height }]`), the argument is a list of an input object type:

```csharp
public static int GetBulkEstimate(
[Parent] Product product,
[Require("dimensions[{ weight, height }]")] ProductDimensionInput[] dimensions)
Comment on lines +266 to +271
=> ShippingCalculator.Bulk(dimensions);
```

## Declaring Contextually Available Fields

Use `@provides` on a field that returns an entity to tell the gateway that certain subfields of that entity are available when resolved through this specific field. The subgraph does not own those fields globally, but it can provide them in this context.
Expand Down
Loading