diff --git a/src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/TypeFileBuilderBase.cs b/src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/TypeFileBuilderBase.cs index 0c315adf325..7172b8cab96 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/TypeFileBuilderBase.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/TypeFileBuilderBase.cs @@ -462,7 +462,9 @@ private void WriteResolverBindingExtendsWith( } } - if (resolver.DescriptorAttributes.Length > 0 || resolver.IsNodeResolver) + if (resolver.DescriptorAttributes.Length > 0 + || resolver.IsNodeResolver + || resolver.Kind is ResolverKind.ConnectionResolver) { Writer.WriteLine(); Writer.WriteIndentedLine("configuration.Member = context.ThisType.GetMethod("); @@ -510,7 +512,11 @@ private void WriteResolverBindingExtendsWith( } } - if (resolver.DescriptorAttributes.Length > 0) + var needsUseConnection = resolver.Kind is ResolverKind.ConnectionResolver + && !resolver.DescriptorAttributes.Any(a => + a.AttributeClass?.ToDisplayString() == WellKnownAttributes.UseConnectionAttribute); + + if (resolver.DescriptorAttributes.Length > 0 || needsUseConnection) { Writer.WriteLine(); Writer.WriteIndentedLine( @@ -526,6 +532,14 @@ private void WriteResolverBindingExtendsWith( Writer.WriteIndentedLine("configuration.Member,"); var first = true; + + if (needsUseConnection) + { + Writer.WriteIndent(); + Writer.Write("new global::HotChocolate.Types.UseConnectionAttribute()"); + first = false; + } + foreach (var attribute in resolver.DescriptorAttributes) { if (!first) diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_ConnectionFlags.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_ConnectionFlags.md index 811b8d36371..189b744a12b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_ConnectionFlags.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_ConnectionFlags.md @@ -357,6 +357,25 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::HotChocolate.Types.Pagination.ConnectionFlags), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_MatchesSnapshot.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_MatchesSnapshot.md index 555b1dec77b..ff50edbc28b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_MatchesSnapshot.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_MatchesSnapshot.md @@ -322,6 +322,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_No_Duplicates_MatchesSnapshot.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_No_Duplicates_MatchesSnapshot.md index 14ff4747d76..0fdf031c006 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_No_Duplicates_MatchesSnapshot.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_CustomConnection_No_Duplicates_MatchesSnapshot.md @@ -315,6 +315,25 @@ namespace TestNamespace.Types.Nodes var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::TestNamespace.Author), + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); @@ -432,6 +451,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); @@ -454,6 +491,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthors2Async", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthors2Async(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_MatchesSnapshot.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_MatchesSnapshot.md index 2dc7ffebf7c..05c7cd6056d 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_MatchesSnapshot.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_MatchesSnapshot.md @@ -321,6 +321,25 @@ namespace TestNamespace.Types.Nodes var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::TestNamespace.Author), + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, @@ -439,6 +458,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, @@ -462,6 +499,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthors2Async", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthors2Async(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_WithConnectionName_MatchesSnapshot.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_WithConnectionName_MatchesSnapshot.md index 8cea2bebc1f..f9adf8bdf1f 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_WithConnectionName_MatchesSnapshot.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_GenericCustomConnection_WithConnectionName_MatchesSnapshot.md @@ -321,6 +321,25 @@ namespace TestNamespace.Types.Nodes var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::TestNamespace.Author), + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, @@ -439,6 +458,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Inherit_PageEdge.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Inherit_PageEdge.md index c6a1f9cf269..ad125ac4bf4 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Inherit_PageEdge.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Inherit_PageEdge.md @@ -357,6 +357,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge.md index 0c31d66c20c..19b67daa31c 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge.md @@ -328,6 +328,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge_Generic.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge_Generic.md index 4bf0b838a13..7898f582fe6 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge_Generic.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_ConnectionBase_Reuse_PageEdge_Generic.md @@ -334,6 +334,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_PageConnection.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_PageConnection.md index bc15a7b21ea..4a44699b889 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_PageConnection.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.GenerateSource_Inherit_From_PageConnection.md @@ -367,6 +367,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class.md index 75d7fd07ea9..5c87391217d 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class.md @@ -324,6 +324,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class_Scoped.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class_Scoped.md index 83a368eddef..ff98034fb83 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class_Scoped.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Class_Scoped.md @@ -326,6 +326,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Field.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Field.md index 664dd0620dd..1146a8aefc4 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Field.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Connection_Field.md @@ -323,6 +323,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class.md index 7a809ed967c..d2f75da5a7a 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class.md @@ -324,6 +324,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class_Scoped.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class_Scoped.md index 39ce816d419..80e8417fa62 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class_Scoped.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Class_Scoped.md @@ -324,6 +324,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Field.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Field.md index b435569087a..454f3c2373b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Field.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_Edge_Field.md @@ -323,6 +323,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection.md index f3dc006ba73..1ea01e9879b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection.md @@ -371,6 +371,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection_Scoped.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection_Scoped.md index dd521e06a99..218d7be85a1 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection_Scoped.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Inaccessible_On_PageConnection_Scoped.md @@ -374,6 +374,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class.md index 2bc49bebe0d..bf6c4ddd54d 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class.md @@ -319,6 +319,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class_Scoped.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class_Scoped.md index fcda35edae1..ea7ecb862bf 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class_Scoped.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Class_Scoped.md @@ -326,6 +326,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Field.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Field.md index 119b37ed851..1f77ddc7f53 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Field.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Connection_Field.md @@ -323,6 +323,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class.md index 8ad2e03d79d..161461db6c5 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class.md @@ -319,6 +319,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class_Scoped.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class_Scoped.md index 2c1aea0bf70..818e301cd42 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class_Scoped.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Class_Scoped.md @@ -324,6 +324,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Field.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Field.md index 4502f046821..37b0e6eb8be 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Field.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_Edge_Field.md @@ -323,6 +323,24 @@ namespace TestNamespace var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection.md index 3d5c07ac618..5723073829f 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection.md @@ -361,6 +361,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection_Scoped.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection_Scoped.md index 2a40a3fddaf..ac2161ef126 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection_Scoped.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/PagingTests.Shareable_On_PageConnection_Scoped.md @@ -374,6 +374,24 @@ namespace TestNamespace.Types.Root var pagingOptions = global::HotChocolate.Types.Pagination.PagingHelper.GetPagingOptions(field.Context, null); configuration.Features.Set(pagingOptions); + configuration.Member = context.ThisType.GetMethod( + "GetAuthorsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetAuthorsAsync(); }, (Resolvers: resolvers, ThisType: thisType)); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.CorrectGenericTypeMatch_NoError.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.CorrectGenericTypeMatch_NoError.md index 53666f9c203..d8c663981cc 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.CorrectGenericTypeMatch_NoError.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.CorrectGenericTypeMatch_NoError.md @@ -386,6 +386,26 @@ namespace TestNamespace configuration.Arguments.Add(argumentConfiguration); } + configuration.Member = context.ThisType.GetMethod( + "GetProductsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::GreenDonut.Data.QueryContext), + typeof(global::TestNamespace.ProductService), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetProductsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.NoQueryContextParameter_NoError.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.NoQueryContextParameter_NoError.md index 9e167404852..283f00c5ea0 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.NoQueryContextParameter_NoError.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.NoQueryContextParameter_NoError.md @@ -386,6 +386,25 @@ namespace TestNamespace configuration.Arguments.Add(argumentConfiguration); } + configuration.Member = context.ThisType.GetMethod( + "GetProductsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::TestNamespace.ProductService), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetProductsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithMutationType_RaisesError.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithMutationType_RaisesError.md index f45c2b038fd..ed91e41bc37 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithMutationType_RaisesError.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithMutationType_RaisesError.md @@ -111,6 +111,26 @@ namespace TestNamespace configuration.Arguments.Add(argumentConfiguration); } + configuration.Member = context.ThisType.GetMethod( + "AddProductsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::GreenDonut.Data.QueryContext), + typeof(global::TestNamespace.ProductService), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.AddProductsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithObjectType_RaisesError.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithObjectType_RaisesError.md index d2f733fd6e5..f5d66d7e969 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithObjectType_RaisesError.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithObjectType_RaisesError.md @@ -386,6 +386,26 @@ namespace TestNamespace configuration.Arguments.Add(argumentConfiguration); } + configuration.Member = context.ThisType.GetMethod( + "GetProductsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::GreenDonut.Data.QueryContext), + typeof(global::TestNamespace.ProductService), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetProductsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithQueryType_RaisesError.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithQueryType_RaisesError.md index c25c0942e75..c885c8aaf52 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithQueryType_RaisesError.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithQueryType_RaisesError.md @@ -398,6 +398,26 @@ namespace TestNamespace configuration.Arguments.Add(argumentConfiguration); } + configuration.Member = context.ThisType.GetMethod( + "GetProductsAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::GreenDonut.Data.QueryContext), + typeof(global::TestNamespace.ProductService), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.GetProductsAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithSubscriptionType_RaisesError.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithSubscriptionType_RaisesError.md index d2b8d73b29a..a430b34c9d1 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithSubscriptionType_RaisesError.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/QueryContextConnectionAnalyzerTests.TypeMismatch_WithSubscriptionType_RaisesError.md @@ -398,6 +398,26 @@ namespace TestNamespace configuration.Arguments.Add(argumentConfiguration); } + configuration.Member = context.ThisType.GetMethod( + "OnProductAddedAsync", + global::HotChocolate.Utilities.ReflectionUtils.StaticMemberFlags, + new global::System.Type[] + { + typeof(global::GreenDonut.Data.PagingArguments), + typeof(global::GreenDonut.Data.QueryContext), + typeof(global::TestNamespace.ProductService), + typeof(global::System.Threading.CancellationToken) + })!; + + var fieldDescriptor = global::HotChocolate.Types.Descriptors.ObjectFieldDescriptor.From(field.Context, configuration); + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + field.Context, + fieldDescriptor, + configuration.Member, + new global::HotChocolate.Types.UseConnectionAttribute()); + configuration.ConfigurationsAreApplied = true; + fieldDescriptor.CreateConfiguration(); + configuration.Resolvers = context.Resolvers.OnProductAddedAsync(); configuration.ResultPostProcessor = global::HotChocolate.Execution.ListPostProcessor.Default; }, diff --git a/src/HotChocolate/Data/test/Data.PostgreSQL.Tests/IntegrationTests.cs b/src/HotChocolate/Data/test/Data.PostgreSQL.Tests/IntegrationTests.cs index 618ef5b2cff..fb1761a4dec 100644 --- a/src/HotChocolate/Data/test/Data.PostgreSQL.Tests/IntegrationTests.cs +++ b/src/HotChocolate/Data/test/Data.PostgreSQL.Tests/IntegrationTests.cs @@ -672,7 +672,57 @@ public async Task Query_ScopeState_With_Derived_ScopedState_Attribute() """); } - private static ServiceProvider CreateServer(string connectionString) + [Fact] + public async Task MaxPageSize_Should_Be_Enforced_On_Connection_Without_UseConnection() + { + // BrandQueries.GetBrandsAsync returns CatalogConnection WITHOUT + // an explicit [UseConnection] attribute. The source generator should + // auto-inject UseConnectionAttribute, which adds the validation middleware + // that enforces MaxPageSize. + var db = "db_" + Guid.NewGuid().ToString("N"); + var connectionString = resource.GetConnectionString(db); + await using var services = CreateServer(connectionString, maxPageSize: 2); + await using var scope = services.CreateAsyncScope(); + var context = scope.ServiceProvider.GetRequiredService(); + var seeder = scope.ServiceProvider.GetRequiredService>(); + await context.Database.EnsureCreatedAsync(); + await seeder.SeedAsync(context); + var executor = await services.GetRequiredService().GetExecutorAsync(); + + var result = await executor.ExecuteAsync( + """ + { + brands(first: 5) { + nodes { + name + } + } + } + """); + + result.MatchInlineSnapshot( + """ + { + "errors": [ + { + "message": "The maximum allowed items per page were exceeded.", + "path": [ + "brands" + ], + "extensions": { + "code": "HC0051", + "coordinate": "Query.brands", + "requestedItems": 5, + "maxAllowedItems": 2 + } + } + ], + "data": null + } + """); + } + + private static ServiceProvider CreateServer(string connectionString, int? maxPageSize = null) { var services = new ServiceCollection(); @@ -697,7 +747,15 @@ private static ServiceProvider CreateServer(string connectionString) .AddSorting() .AddNodeIdValueSerializerFrom() .ModifyRequestOptions(o => o.IncludeExceptionDetails = true) - .ModifyPagingOptions(o => o.RelativeCursorFields = o.RelativeCursorFields.Add("endCursors")); + .ModifyPagingOptions(o => + { + o.RelativeCursorFields = o.RelativeCursorFields.Add("endCursors"); + + if (maxPageSize.HasValue) + { + o.MaxPageSize = maxPageSize.Value; + } + }); services.AddSingleton, CatalogContextSeed>();