Skip to content
Merged
Show file tree
Hide file tree
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 @@ -262,8 +262,8 @@ public class CustomFilteringConvention : FilterConvention
descriptor.Provider(
new QueryableFilterProvider(
x => x
.AddDefaultFieldHandlers()
.AddFieldHandler<QueryableStringInvariantEqualsHandler>()));
.AddFieldHandler(ctx => new QueryableStringInvariantEqualsHandler(ctx.InputParser))
.AddDefaultFieldHandlers()));
}
}

Expand All @@ -272,6 +272,8 @@ builder
.AddFiltering<CustomFilteringConvention>();
```

> Warning: Register custom handlers **before** `AddDefaultFieldHandlers()`. If a default handler covers the same operation (for example `eq` on strings), the one registered first wins, and your custom handler will be silently ignored.

You can also use convention and provider extensions instead of creating a custom `FilterConvention`:

```csharp
Expand All @@ -282,7 +284,7 @@ builder
new FilterConventionExtension(
x => x.AddProviderExtension(
new QueryableFilterProviderExtension(
y => y.AddFieldHandler<QueryableStringInvariantEqualsHandler>()))));
y => y.AddFieldHandler(ctx => new QueryableStringInvariantEqualsHandler(ctx.InputParser))))));
```

# Next Steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,55 @@ If you're using the schema export command, add the `--semantic-non-null` flag to
dotnet run -- schema export --output schema.graphql --semantic-non-null
```

## Parameterless handler registration on filter, sort, and projection providers removed

The parameterless activator overloads have been removed from the filtering, sorting, and projection provider descriptors. Custom handlers must now be registered either by passing an instance or by passing a factory that receives a provider context. The context exposes `InputParser`, `InputFormatter`, `SchemaServices`, `TypeConverter`, etc.
Comment thread
tobias-tengler marked this conversation as resolved.

Affected APIs:

- `IFilterProviderDescriptor<TContext>.AddFieldHandler<T>()` -> `AddFieldHandler(Func<FilterProviderContext, T>)`
- `ISortProviderDescriptor<TContext>.AddFieldHandler<T>()` -> `AddFieldHandler(Func<SortProviderContext, T>)`
- `ISortProviderDescriptor<TContext>.AddOperationHandler<T>()` -> `AddOperationHandler(Func<SortProviderContext, T>)`
- `IProjectionProviderDescriptor.RegisterFieldHandler<T>()` -> `RegisterFieldHandler(Func<ProjectionProviderContext, T>)`
- `IProjectionProviderDescriptor.RegisterFieldInterceptor<T>()` -> `RegisterFieldInterceptor(Func<ProjectionProviderContext, T>)`
- `IProjectionProviderDescriptor.RegisterOptimizer<T>()` -> `RegisterOptimizer(Func<ProjectionProviderContext, T>)`

**Before**

```csharp
public class CustomFilteringConvention : FilterConvention
{
protected override void Configure(IFilterConventionDescriptor descriptor)
{
descriptor.AddDefaults();
descriptor.Provider(
new QueryableFilterProvider(
x => x
.AddFieldHandler<QueryableStringInvariantEqualsHandler>()
.AddDefaultFieldHandlers()));
}
}
```

**After**

```csharp
public class CustomFilteringConvention : FilterConvention
{
protected override void Configure(IFilterConventionDescriptor descriptor)
{
descriptor.AddDefaults();
descriptor.Provider(
new QueryableFilterProvider(
x => x
.AddFieldHandler(ctx => new QueryableStringInvariantEqualsHandler(ctx.InputParser))
.AddDefaultFieldHandlers()));
}
Comment thread
tobias-tengler marked this conversation as resolved.
}
```

The `CanHandle` signature also changed on the filtering, sorting, and projection handler interfaces. If you have overridden it, re-override against the new signature.

# Deprecations

Things that will continue to function this release, but we encourage you to move away from.
Expand Down