diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Paging.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Paging.cs index 988047b6953..0a852c14265 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Paging.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.Paging.cs @@ -26,6 +26,7 @@ public static partial class SchemaRequestExecutorBuilderExtensions /// /// The is null. /// + [Obsolete("Use ModifyPagingOptions instead.")] public static IRequestExecutorBuilder SetPagingOptions( this IRequestExecutorBuilder builder, PagingOptions options) @@ -37,4 +38,30 @@ public static IRequestExecutorBuilder SetPagingOptions( return builder.ConfigureSchema(s => s.SetPagingOptions(options)); } + + /// + /// Modifies the global paging options. + /// + /// + /// The . + /// + /// + /// A delegate to modify the paging options. + /// + public static IRequestExecutorBuilder ModifyPagingOptions( + this IRequestExecutorBuilder builder, + Action configure) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (configure is null) + { + throw new ArgumentNullException(nameof(configure)); + } + + return builder.ConfigureSchema(s => s.ModifyPagingOptions(configure)); + } } diff --git a/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.cs b/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.cs index 728a51d84ea..a1bf3e2a3ec 100644 --- a/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/Core/src/Execution/DependencyInjection/SchemaRequestExecutorBuilderExtensions.cs @@ -10,6 +10,7 @@ namespace Microsoft.Extensions.DependencyInjection; /// public static partial class SchemaRequestExecutorBuilderExtensions { + [Obsolete("Use ModifyOptions instead.")] public static IRequestExecutorBuilder SetOptions( this IRequestExecutorBuilder builder, IReadOnlySchemaOptions options) diff --git a/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/PagingObjectFieldDescriptorExtensions.cs b/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/PagingObjectFieldDescriptorExtensions.cs index 4ca3d7523c0..c554f7b4b5a 100644 --- a/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/PagingObjectFieldDescriptorExtensions.cs +++ b/src/HotChocolate/Core/src/Types.CursorPagination/Extensions/PagingObjectFieldDescriptorExtensions.cs @@ -39,7 +39,7 @@ public static IObjectFieldDescriptor UsePaging( this IObjectFieldDescriptor descriptor, GetCursorPagingProvider? resolvePagingProvider = null, string? connectionName = null, - PagingOptions options = default) + PagingOptions? options = null) where TNodeType : class, IOutputType => UsePaging( descriptor, @@ -73,7 +73,7 @@ public static IObjectFieldDescriptor UsePaging( Type? entityType = null, GetCursorPagingProvider? resolvePagingProvider = null, string? connectionName = null, - PagingOptions options = default) + PagingOptions? options = null) where TNodeType : class, IOutputType => UsePaging( descriptor, @@ -112,7 +112,7 @@ public static IObjectFieldDescriptor UsePaging( Type? entityType = null, GetCursorPagingProvider? resolvePagingProvider = null, string? connectionName = null, - PagingOptions options = default) + PagingOptions? options = null) { if (descriptor is null) { @@ -131,7 +131,7 @@ public static IObjectFieldDescriptor UsePaging( .Extend() .OnBeforeCreate((c, d) => { - var pagingOptions = c.GetSettings(options); + var pagingOptions = c.GetPagingOptions(options); var backward = pagingOptions.AllowBackwardPagination ?? AllowBackwardPagination; d.State = d.State.Add(WellKnownContextData.PagingOptions, pagingOptions); d.Flags |= FieldFlags.Connection; @@ -199,7 +199,7 @@ d.Type is ExtendedTypeReference extendedTypeRef && public static IInterfaceFieldDescriptor UsePaging( this IInterfaceFieldDescriptor descriptor, string? connectionName = null, - PagingOptions options = default) + PagingOptions? options = null) where TNodeType : class, IOutputType => UsePaging(descriptor, typeof(TNodeType), connectionName, options); @@ -207,7 +207,7 @@ public static IInterfaceFieldDescriptor UsePaging( this IInterfaceFieldDescriptor descriptor, Type? nodeType = null, string? connectionName = null, - PagingOptions options = default) + PagingOptions? options = null) { if (descriptor is null) { @@ -218,7 +218,7 @@ public static IInterfaceFieldDescriptor UsePaging( .Extend() .OnBeforeCreate((c, d) => { - var pagingOptions = c.GetSettings(options); + var pagingOptions = c.GetPagingOptions(options); var backward = pagingOptions.AllowBackwardPagination ?? AllowBackwardPagination; d.State = d.State.Add(WellKnownContextData.PagingOptions, pagingOptions); d.Flags |= FieldFlags.Connection; @@ -332,7 +332,7 @@ private static TypeReference CreateConnectionTypeRef( MemberInfo? resolverMember, string? connectionName, TypeReference? nodeType, - PagingOptions options) + PagingOptions? options) { var typeInspector = context.TypeInspector; @@ -355,7 +355,7 @@ private static TypeReference CreateConnectionTypeRef( namedType); } - options = context.GetSettings(options); + options = context.GetPagingOptions(options); // last but not least we create a type reference that can be put on the field definition // to tell the type discovery that this field needs this result type. diff --git a/src/HotChocolate/Core/src/Types.OffsetPagination/Extensions/OffsetPagingObjectFieldDescriptorExtensions.cs b/src/HotChocolate/Core/src/Types.OffsetPagination/Extensions/OffsetPagingObjectFieldDescriptorExtensions.cs index 88acb06d04e..dc37a757065 100644 --- a/src/HotChocolate/Core/src/Types.OffsetPagination/Extensions/OffsetPagingObjectFieldDescriptorExtensions.cs +++ b/src/HotChocolate/Core/src/Types.OffsetPagination/Extensions/OffsetPagingObjectFieldDescriptorExtensions.cs @@ -46,7 +46,7 @@ public static IObjectFieldDescriptor UseOffsetPaging( Type? itemType = null, GetOffsetPagingProvider? resolvePagingProvider = null, string? collectionSegmentName = null, - PagingOptions options = default) + PagingOptions? options = null) where TSchemaType : IOutputType => UseOffsetPaging( descriptor, @@ -86,7 +86,7 @@ public static IObjectFieldDescriptor UseOffsetPaging( Type? entityType = null, GetOffsetPagingProvider? resolvePagingProvider = null, string? collectionSegmentName = null, - PagingOptions options = default) + PagingOptions? options = null) { if (descriptor is null) { @@ -107,7 +107,7 @@ public static IObjectFieldDescriptor UseOffsetPaging( .Extend() .OnBeforeCreate((c, d) => { - var pagingOptions = c.GetSettings(options); + var pagingOptions = c.GetPagingOptions(options); if (string.IsNullOrEmpty(collectionSegmentName)) { collectionSegmentName = @@ -159,7 +159,7 @@ d.Type is SyntaxTypeReference syntaxTypeRef && public static IInterfaceFieldDescriptor UseOffsetPaging( this IInterfaceFieldDescriptor descriptor, string? collectionSegmentName = null, - PagingOptions options = default) + PagingOptions? options = null) where TSchemaType : class, IOutputType => UseOffsetPaging(descriptor, typeof(TSchemaType), collectionSegmentName, options); @@ -185,7 +185,7 @@ public static IInterfaceFieldDescriptor UseOffsetPaging( this IInterfaceFieldDescriptor descriptor, Type? itemType = null, string? collectionSegmentName = null, - PagingOptions options = default) + PagingOptions? options = null) { if (descriptor is null) { @@ -198,7 +198,7 @@ public static IInterfaceFieldDescriptor UseOffsetPaging( .Extend() .OnBeforeCreate((c, d) => { - var pagingOptions = c.GetSettings(options); + var pagingOptions = c.GetPagingOptions(options); if (string.IsNullOrEmpty(collectionSegmentName)) { collectionSegmentName = @@ -267,7 +267,7 @@ private static TypeReference CreateTypeRef( MemberInfo? resolverMember, string? collectionSegmentName, TypeReference? itemsType, - PagingOptions options) + PagingOptions? options) { var typeInspector = context.TypeInspector; @@ -285,7 +285,7 @@ private static TypeReference CreateTypeRef( namedType); } - options = context.GetSettings(options); + options = context.GetPagingOptions(options); // last but not leas we create a type reference that can be put on the field definition // to tell the type discovery that this field needs this result type. diff --git a/src/HotChocolate/Core/src/Types/Contracts/ISchemaBuilder.cs b/src/HotChocolate/Core/src/Types/Contracts/ISchemaBuilder.cs index 5e1c033ffdd..a0b7a000d95 100644 --- a/src/HotChocolate/Core/src/Types/Contracts/ISchemaBuilder.cs +++ b/src/HotChocolate/Core/src/Types/Contracts/ISchemaBuilder.cs @@ -6,6 +6,7 @@ using HotChocolate.Resolvers; using HotChocolate.Types; using HotChocolate.Types.Descriptors; +using HotChocolate.Types.Pagination; #nullable enable @@ -31,9 +32,15 @@ public interface ISchemaBuilder ISchemaBuilder SetSchema(Action configure); + [Obsolete("Use ModifyOptions instead.")] ISchemaBuilder SetOptions(IReadOnlySchemaOptions options); ISchemaBuilder ModifyOptions(Action configure); + + [Obsolete("Use ModifyPagingOptions instead.")] + ISchemaBuilder SetPagingOptions(PagingOptions options); + + ISchemaBuilder ModifyPagingOptions(Action configure); ISchemaBuilder Use(FieldMiddleware middleware); diff --git a/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Paging.cs b/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Paging.cs deleted file mode 100644 index 62e966f0a82..00000000000 --- a/src/HotChocolate/Core/src/Types/Extensions/SchemaBuilderExtensions.Paging.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using HotChocolate.Types.Pagination; - -namespace HotChocolate; - -public static partial class SchemaBuilderExtensions -{ - public static ISchemaBuilder SetPagingOptions( - this ISchemaBuilder builder, - PagingOptions options) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.SetContextData(typeof(PagingOptions).FullName!, options); - } -} diff --git a/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs b/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs index 26559f0bd2d..750b3c893db 100644 --- a/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs +++ b/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs @@ -12,6 +12,7 @@ using HotChocolate.Types.Factories; using HotChocolate.Types.Helpers; using HotChocolate.Types.Interceptors; +using HotChocolate.Types.Pagination; using HotChocolate.Types.Relay; using HotChocolate.Utilities; using HotChocolate.Utilities.Introspection; @@ -104,6 +105,8 @@ public static DescriptorContext CreateContext( lazySchema, typeInterceptor); + context.ContextData[typeof(PagingOptions).FullName!] = builder._pagingOptions; + return context; } diff --git a/src/HotChocolate/Core/src/Types/SchemaBuilder.cs b/src/HotChocolate/Core/src/Types/SchemaBuilder.cs index 8ba1bb69b05..f96d09c9646 100644 --- a/src/HotChocolate/Core/src/Types/SchemaBuilder.cs +++ b/src/HotChocolate/Core/src/Types/SchemaBuilder.cs @@ -7,7 +7,6 @@ using HotChocolate.Resolvers; using HotChocolate.Types; using HotChocolate.Types.Descriptors; -using HotChocolate.Types.Descriptors.Definitions; using HotChocolate.Types.Factories; using HotChocolate.Types.Interceptors; using HotChocolate.Types.Introspection; @@ -43,6 +42,7 @@ public partial class SchemaBuilder : ISchemaBuilder ]; private SchemaOptions _options = new(); + private PagingOptions _pagingOptions = new(); private IsOfTypeFallback? _isOfType; private IServiceProvider? _services; private CreateRef? _schema; @@ -105,6 +105,7 @@ public ISchemaBuilder SetSchema(Action configure) } /// + [Obsolete("Use ModifyOptions instead.")] public ISchemaBuilder SetOptions(IReadOnlySchemaOptions options) { if (options is null) @@ -128,6 +129,26 @@ public ISchemaBuilder ModifyOptions(Action configure) return this; } + /// + [Obsolete("Use ModifyPagingOptions instead.")] + public ISchemaBuilder SetPagingOptions(PagingOptions options) + { + _pagingOptions = options; + return this; + } + + /// + public ISchemaBuilder ModifyPagingOptions(Action configure) + { + if (configure is null) + { + throw new ArgumentNullException(nameof(configure)); + } + + configure(_pagingOptions); + return this; + } + /// public ISchemaBuilder Use(FieldMiddleware middleware) { @@ -455,24 +476,4 @@ public ISchemaBuilder TryAddTypeInterceptor(TypeInterceptor interceptor) /// Returns a new instance of . /// public static SchemaBuilder New() => new(); - - private sealed class CopyOptions : TypeInterceptor - { - public override void OnBeforeCompleteType(ITypeCompletionContext completionContext, DefinitionBase definition) - { - if (definition is SchemaTypeDefinition schemaDef) - { - var key = typeof(PagingOptions).FullName!; - - if (completionContext.DescriptorContext.ContextData.TryGetValue(key, out var value)) - { - schemaDef.ContextData[key] = value; - } - else - { - schemaDef.ContextData[key] = new PagingOptions(); - } - } - } - } } diff --git a/src/HotChocolate/Core/src/Types/Types/Pagination/PagingHelper.cs b/src/HotChocolate/Core/src/Types/Types/Pagination/PagingHelper.cs index a422f64dfaf..d15c7fb830c 100644 --- a/src/HotChocolate/Core/src/Types/Types/Pagination/PagingHelper.cs +++ b/src/HotChocolate/Core/src/Types/Types/Pagination/PagingHelper.cs @@ -15,13 +15,13 @@ namespace HotChocolate.Types.Pagination; -public static class PagingHelper +internal static class PagingHelper { public static IObjectFieldDescriptor UsePaging( IObjectFieldDescriptor descriptor, Type? entityType, GetPagingProvider resolvePagingProvider, - PagingOptions options) + PagingOptions? options) { if (descriptor is null) { @@ -38,7 +38,7 @@ public static IObjectFieldDescriptor UsePaging( c, d, entityType, - options.ProviderName, + options?.ProviderName, resolvePagingProvider, options, placeholder), @@ -54,10 +54,10 @@ private static void ApplyConfiguration( Type? entityType, string? name, GetPagingProvider resolvePagingProvider, - PagingOptions options, + PagingOptions? options, FieldMiddlewareDefinition placeholder) { - options = context.GetSettings(options); + options = context.GetPagingOptions(options); entityType ??= context.GetType(definition.Type!).ToRuntimeType(); var source = GetSourceType(context.TypeInspector, definition, entityType); @@ -194,16 +194,16 @@ public static bool TryGetNamedType( return false; } - public static PagingOptions GetSettings( + public static PagingOptions GetPagingOptions( this ITypeCompletionContext context, - PagingOptions options) => - context.DescriptorContext.GetSettings(options); + PagingOptions? options) => + context.DescriptorContext.GetPagingOptions(options); - public static PagingOptions GetSettings( + public static PagingOptions GetPagingOptions( this IDescriptorContext context, - PagingOptions options) + PagingOptions? options) { - options = options.Copy(); + options = options?.Copy() ?? new(); if (context.ContextData.TryGetValue(typeof(PagingOptions).FullName!, out var o) && o is PagingOptions global) diff --git a/src/HotChocolate/Core/src/Types/Types/Pagination/PagingOptions.cs b/src/HotChocolate/Core/src/Types/Types/Pagination/PagingOptions.cs index 608d2bb84d6..9d65392f573 100644 --- a/src/HotChocolate/Core/src/Types/Types/Pagination/PagingOptions.cs +++ b/src/HotChocolate/Core/src/Types/Types/Pagination/PagingOptions.cs @@ -5,7 +5,7 @@ namespace HotChocolate.Types.Pagination; /// /// The paging options. /// -public struct PagingOptions +public class PagingOptions { /// /// Gets or sets the default page size. diff --git a/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_SchemaOptionsTests.cs b/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_SchemaOptionsTests.cs index e0c0d53af33..50ecf3142f1 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_SchemaOptionsTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_SchemaOptionsTests.cs @@ -7,14 +7,14 @@ namespace HotChocolate.Execution.DependencyInjection; public class RequestExecutorBuilderExtensionsSchemaOptionsTests { [Fact] - public async Task SetOptions_ValidatePipelineOrder_False() + public async Task ModifyOptions_ValidatePipelineOrder_False() { var interceptor = new OptionsInterceptor(); await new ServiceCollection() .AddGraphQLServer() .AddType() - .SetOptions(new SchemaOptions { ValidatePipelineOrder = false, }) + .ModifyOptions(o => o.ValidatePipelineOrder = false) .TryAddTypeInterceptor(interceptor) .BuildRequestExecutorAsync(); diff --git a/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs index f9a6458c618..e38bb26f875 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Processing/SelectionIncludeConditionTests.cs @@ -642,7 +642,7 @@ public async Task Nested_Skips() await new ServiceCollection() .AddGraphQLServer() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .ExecuteRequestAsync( OperationRequestBuilder.New() .SetDocument( diff --git a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/IntegrationTests.cs b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/IntegrationTests.cs index 5dd99c74d26..817048d4dff 100644 --- a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/IntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/IntegrationTests.cs @@ -86,7 +86,7 @@ public async Task No_Boundaries_Set() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = true, }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = true) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -219,7 +219,7 @@ public async Task MaxPageSizeReached_First() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { MaxPageSize = 2, }) + .ModifyPagingOptions(o => o.MaxPageSize = 2) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -286,7 +286,7 @@ public async Task MaxPageSizeReached_Last() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { MaxPageSize = 2, }) + .ModifyPagingOptions(o => o.MaxPageSize = 2) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -419,7 +419,7 @@ public async Task Simple_StringList_Global_DefaultItem_2() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 2, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 2) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -453,7 +453,7 @@ public async Task Attribute_Simple_StringList_Global_DefaultItem_2() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 2, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 2) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -787,7 +787,7 @@ public async Task Deactivate_BackwardPagination() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { AllowBackwardPagination = false, }) + .ModifyPagingOptions(o => o.AllowBackwardPagination = false) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -804,7 +804,7 @@ public async Task Deactivate_BackwardPagination_Interface() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { AllowBackwardPagination = false, }) + .ModifyPagingOptions(o => o.AllowBackwardPagination = false) .AddInterfaceType(d => d.Field(t => t.ExplicitType()).UsePaging()) .Services .BuildServiceProvider() @@ -855,7 +855,7 @@ public async Task SelectProviderByName() .AddGraphQL() .AddQueryType() .AddCursorPagingProvider(providerName: "Abc") - .SetPagingOptions(new PagingOptions { InferConnectionNameFromField = false, }) + .ModifyPagingOptions(o => o.InferConnectionNameFromField = false) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -963,7 +963,7 @@ public async Task TotalCountWithCustomConnection() // assert result.ToJson().MatchSnapshot(); } - + [Fact] public async Task Invalid_After_Index_Cursor() { @@ -987,10 +987,10 @@ public async Task Invalid_After_Index_Cursor() } } """); - + await result.MatchSnapshotAsync(); } - + [Fact] public async Task Invalid_Before_Index_Cursor() { @@ -1014,7 +1014,7 @@ public async Task Invalid_Before_Index_Cursor() } } """); - + await result.MatchSnapshotAsync(); } diff --git a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/QueryableCursorPagingProviderTests.cs b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/QueryableCursorPagingProviderTests.cs index febdf63f646..95a7e7516e1 100644 --- a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/QueryableCursorPagingProviderTests.cs +++ b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/QueryableCursorPagingProviderTests.cs @@ -27,7 +27,7 @@ public async Task TakeFirst() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -69,7 +69,7 @@ public async Task TakeLastSingle() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "f", "g", }; @@ -105,7 +105,7 @@ public async Task TakeLast() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -146,7 +146,7 @@ public async Task TakeFirstAfter() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -192,7 +192,7 @@ public async Task TakeLastBefore() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -238,7 +238,7 @@ public async Task HasNextPage_True() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -261,7 +261,7 @@ public async Task HasNextPage_False() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -284,7 +284,7 @@ public async Task HasPrevious_True() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -313,7 +313,7 @@ public async Task HasPrevious_False() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new List { "a", "b", "c", "d", "e", "f", "g", }; @@ -336,7 +336,7 @@ public async Task Executable() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new MockExecutable(new [] { @@ -386,7 +386,7 @@ public async Task Executable_Queryable() var sourceType = typeInspector.GetType(typeof(List)); IPagingProvider pagingProvider = new QueryableCursorPagingProvider(); - var pagingHandler = pagingProvider.CreateHandler(sourceType, default); + var pagingHandler = pagingProvider.CreateHandler(sourceType, new()); var list = new MockExecutable(new [] { diff --git a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/IntegrationTests.cs b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/IntegrationTests.cs index 688fe0acf2d..1d57096671e 100644 --- a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/IntegrationTests.cs +++ b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/IntegrationTests.cs @@ -79,7 +79,7 @@ public async Task No_Paging_Boundaries() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = true, }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = true) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -107,7 +107,7 @@ public async Task MaxPageSizeReached() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = true, }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = true) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -270,7 +270,7 @@ public async Task Simple_StringList_Global_DefaultItem_2() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 2, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 2) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -298,7 +298,7 @@ public async Task Simple_StringList_Global_DefaultItem_50_Page_Larger_Than_Data_ await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 50, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 50) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); @@ -326,7 +326,7 @@ public async Task Attribute_Simple_StringList_Global_DefaultItem_2() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 2, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 2) .Services .BuildServiceProvider() .GetRequestExecutorAsync(); diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/PaginationTests.cs b/src/HotChocolate/Core/test/Types.Tests/Types/PaginationTests.cs index 619f2e7a4b5..113ccf0491e 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/PaginationTests.cs +++ b/src/HotChocolate/Core/test/Types.Tests/Types/PaginationTests.cs @@ -26,7 +26,7 @@ public async Task Execute_NestedOffsetPaging_NoCyclicDependencies() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 50, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 50) .BuildRequestExecutorAsync(cancellationToken: ct); snapshot.Add( @@ -58,7 +58,7 @@ public async Task Execute_NestedOffsetPaging_With_Indirect_Cycles() await new ServiceCollection() .AddGraphQL() .AddQueryType() - .SetPagingOptions(new PagingOptions { DefaultPageSize = 50, }) + .ModifyPagingOptions(o => o.DefaultPageSize = 50) .BuildRequestExecutorAsync(cancellationToken: ct); snapshot.Add(await executor @@ -155,4 +155,4 @@ protected override void Configure(IObjectTypeDescriptor descriptor) .UseOffsetPaging(); } } -} \ No newline at end of file +} diff --git a/src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/PagingTests.cs b/src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/PagingTests.cs index 21176e5f3c1..d957d6ec4b6 100644 --- a/src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/PagingTests.cs +++ b/src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/PagingTests.cs @@ -55,7 +55,7 @@ public async Task Filtering_Not_Used() await new ServiceCollection() .AddGraphQLServer() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .AddFiltering() .AddSorting() .BuildRequestExecutorAsync(); @@ -366,7 +366,7 @@ public async Task Filtering_Specific_Filter_Used() await new ServiceCollection() .AddGraphQLServer() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .AddFiltering() .AddSorting() .BuildRequestExecutorAsync(); @@ -419,7 +419,7 @@ public async Task Filtering_Specific_Expensive_Filter_Used() await new ServiceCollection() .AddGraphQLServer() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .AddFiltering() .AddSorting() .BuildRequestExecutorAsync(); @@ -472,7 +472,7 @@ public async Task Filtering_Variable() await new ServiceCollection() .AddGraphQLServer() .AddQueryType() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .AddFiltering() .AddSorting() .BuildRequestExecutorAsync(); diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index 0ceaf89f26d..b8298bebb99 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -440,7 +440,7 @@ private TestServer CreateInstrumentedServer( services .AddGraphQLServer() .AddInstrumentation(options) - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false}) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .ModifyOptions( o => { diff --git a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs index 7378b947e6f..fed81022f5b 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Filters.Tests/FilterVisitorTestBase.cs @@ -39,7 +39,7 @@ protected IRequestExecutor CreateSchema( .AddGraphQLServer() .AddRavenFiltering() .AddRavenPagingProviders() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false}) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .AddQueryType( c => { diff --git a/src/HotChocolate/Raven/test/Data.Raven.Tests/AnnotationBasedTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Tests/AnnotationBasedTests.cs index abb01de3e7c..261580d89c9 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Tests/AnnotationBasedTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Tests/AnnotationBasedTests.cs @@ -252,7 +252,7 @@ public async Task Executable_Should_Work() .AddRavenProjections() .AddRavenSorting() .AddRavenPagingProviders() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false}) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .RegisterDocumentStore() .AddQueryType() .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/src/HotChocolate/Raven/test/Data.Raven.Tests/DataExtensionsTests.cs b/src/HotChocolate/Raven/test/Data.Raven.Tests/DataExtensionsTests.cs index b10482571fd..d1af229ed38 100644 --- a/src/HotChocolate/Raven/test/Data.Raven.Tests/DataExtensionsTests.cs +++ b/src/HotChocolate/Raven/test/Data.Raven.Tests/DataExtensionsTests.cs @@ -110,7 +110,7 @@ public async Task OffsetPagination_Should_Work() .AddRavenProjections() .AddRavenSorting() .AddRavenPagingProviders() - .SetPagingOptions(new PagingOptions { RequirePagingBoundaries = false }) + .ModifyPagingOptions(o => o.RequirePagingBoundaries = false) .RegisterDocumentStore() .AddQueryType() .ModifyRequestOptions(x => x.IncludeExceptionDetails = true) diff --git a/templates/StarWars/content/Startup.cs b/templates/StarWars/content/Startup.cs index a8649fba61b..49b7e8bf37d 100644 --- a/templates/StarWars/content/Startup.cs +++ b/templates/StarWars/content/Startup.cs @@ -22,13 +22,13 @@ public void ConfigureServices(IServiceCollection services) .AddSingleton() .AddSingleton() - // Next we are adding our GraphQL server configuration. + // Next we are adding our GraphQL server configuration. // We can host multiple named GraphQL server configurations // that can be exposed on different routes. .AddGraphQLServer() // The query types are split into two classes, - // by splitting the types into several class we can organize + // by splitting the types into several class we can organize // our query fields by topics and also am able to test // them separately. .AddQueryType() @@ -39,8 +39,8 @@ public void ConfigureServices(IServiceCollection services) .AddSubscriptionType() .AddTypeExtension() - // The type discover is very good in exploring the types that we are using - // but sometimes when a GraphQL field for instance only exposes an interface + // The type discover is very good in exploring the types that we are using + // but sometimes when a GraphQL field for instance only exposes an interface // we need to provide we need to provide the implementation types that we want // to host in our GraphQL schema. .AddType() @@ -54,14 +54,14 @@ public void ConfigureServices(IServiceCollection services) // if you wanted to control the pagination settings globally you could // do so by setting the paging options. - // .SetPagingOptions() + // .ModifyPagingOptions() - // Since we are exposing a subscription type we also need a pub/sub system - // handling the subscription events. For our little demo here we will use + // Since we are exposing a subscription type we also need a pub/sub system + // handling the subscription events. For our little demo here we will use // an in-memory pub/sub system. .AddInMemorySubscriptions() - // Last we will add apollo tracing to our server which by default is + // Last we will add apollo tracing to our server which by default is // only activated through the X-APOLLO-TRACING:1 header. .AddApolloTracing(); } @@ -73,7 +73,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseDeveloperExceptionPage(); } - // in order to expose our GraphQL schema we need to map the GraphQL server + // in order to expose our GraphQL schema we need to map the GraphQL server // to a specific route. By default it is mapped onto /graphql. app .UseWebSockets()