diff --git a/src/HotChocolate/Core/src/Abstractions/ModuleOptions.cs b/src/HotChocolate/Core/src/Abstractions/ModuleOptions.cs index 34e275713bc..22fa735f456 100644 --- a/src/HotChocolate/Core/src/Abstractions/ModuleOptions.cs +++ b/src/HotChocolate/Core/src/Abstractions/ModuleOptions.cs @@ -24,5 +24,12 @@ public enum ModuleOptions /// /// Include internal resolver members when discovering source generated types. /// - IncludeInternalMembers = 4 + IncludeInternalMembers = 4, + + /// + /// Disable XML documentation comment extraction for source generated types. + /// When set, only explicit values + /// will be used as descriptions in the generated schema. + /// + DisableXmlDocumentation = 8 } diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Helpers/CompilationExtensions.cs b/src/HotChocolate/Core/src/Types.Analyzers/Helpers/CompilationExtensions.cs index 4e00e005e4c..ab8dbdc8cbb 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Helpers/CompilationExtensions.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Helpers/CompilationExtensions.cs @@ -1,3 +1,4 @@ +using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using HotChocolate.Types.Analyzers.Models; using Microsoft.CodeAnalysis; @@ -88,6 +89,32 @@ public static bool TryGetGraphQLTypeName( this Compilation compilation, ISymbol symbol) { + if (compilation.DisableXmlDocumentation()) + { + switch (symbol) + { + case IPropertySymbol property: + return new PropertyDescription(property.GetDescriptionFromAttribute()); + + case IMethodSymbol method: + var paramDescs = ImmutableArray.CreateBuilder(method.Parameters.Length); + foreach (var p in method.Parameters) + { + paramDescs.Add(p.GetDescriptionFromAttribute()); + } + + return new MethodDescription( + method.GetDescriptionFromAttribute(), + paramDescs.ToImmutable()); + + case IParameterSymbol parameter: + return new ParameterDescription(parameter.GetDescriptionFromAttribute()); + + default: + return null; + } + } + switch (symbol) { case IPropertySymbol property: @@ -104,6 +131,18 @@ public static bool TryGetGraphQLTypeName( } } + public static string? GetDescription( + this Compilation compilation, + INamedTypeSymbol type) + { + if (compilation.DisableXmlDocumentation()) + { + return type.GetDescriptionFromAttribute(); + } + + return type.GetDescription(compilation); + } + public static string? GetDeprecationReason(this Compilation compilation, ISymbol symbol) { var graphQLDeprecatedAttribute = compilation.GetTypeByMetadataName(WellKnownAttributes.GraphQLDeprecatedAttribute); diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Helpers/ModuleOptionsHelper.cs b/src/HotChocolate/Core/src/Types.Analyzers/Helpers/ModuleOptionsHelper.cs index d41790457b2..415bd4b7d30 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Helpers/ModuleOptionsHelper.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Helpers/ModuleOptionsHelper.cs @@ -11,6 +11,10 @@ public static bool IncludeInternalMembers(this Compilation compilation) => (GetModuleOptions(compilation) & ModuleOptions.IncludeInternalMembers) == ModuleOptions.IncludeInternalMembers; + public static bool DisableXmlDocumentation(this Compilation compilation) + => (GetModuleOptions(compilation) & ModuleOptions.DisableXmlDocumentation) + == ModuleOptions.DisableXmlDocumentation; + private static ModuleOptions GetModuleOptions(Compilation compilation) { foreach (var attribute in compilation.Assembly.GetAttributes()) diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/InterfaceTypeInfoInspector.cs b/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/InterfaceTypeInfoInspector.cs index a891b1b89b9..8ac1394de76 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/InterfaceTypeInfoInspector.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/InterfaceTypeInfoInspector.cs @@ -80,6 +80,7 @@ public bool TryHandle(GeneratorSyntaxContext context, [NotNullWhen(true)] out Sy } var interfaceTypeInfo = new InterfaceTypeInfo( + context.SemanticModel.Compilation, classSymbol, runtimeType, possibleType, diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/ObjectTypeInspector.cs b/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/ObjectTypeInspector.cs index 62af7493386..7ff0f8dc5cf 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/ObjectTypeInspector.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Inspectors/ObjectTypeInspector.cs @@ -122,6 +122,7 @@ or Accessibility.ProtectedOrInternal if (runtimeType is not null) { var objectTypeInfo = new ObjectTypeInfo( + context.SemanticModel.Compilation, classSymbol, runtimeType, nodeResolver, @@ -139,6 +140,7 @@ or Accessibility.ProtectedOrInternal } var rootType = new RootTypeInfo( + context.SemanticModel.Compilation, classSymbol, operationType!.Value, possibleType, diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Models/EdgeTypeInfo.cs b/src/HotChocolate/Core/src/Types.Analyzers/Models/EdgeTypeInfo.cs index 1415bf202ef..2a031fbb962 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Models/EdgeTypeInfo.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Models/EdgeTypeInfo.cs @@ -186,7 +186,7 @@ private static EdgeTypeInfo Create( edgeName, nameFormat, @namespace, - runtimeType.GetDescription(), + compilation.GetDescription(runtimeType), runtimeType, classDeclaration, resolvers.ToImmutable(), diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Models/InterfaceTypeInfo.cs b/src/HotChocolate/Core/src/Types.Analyzers/Models/InterfaceTypeInfo.cs index 2ea054d887c..c8f5c2f6a9b 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Models/InterfaceTypeInfo.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Models/InterfaceTypeInfo.cs @@ -8,6 +8,7 @@ namespace HotChocolate.Types.Analyzers.Models; public sealed class InterfaceTypeInfo : SyntaxInfo, IOutputTypeInfo { public InterfaceTypeInfo( + Compilation compilation, INamedTypeSymbol schemaType, INamedTypeSymbol runtimeType, ClassDeclarationSyntax classDeclarationSyntax, @@ -20,7 +21,7 @@ public InterfaceTypeInfo( RuntimeTypeFullName = runtimeType.ToDisplayString(); ClassDeclaration = classDeclarationSyntax; Resolvers = resolvers; - Description = schemaType.GetDescription(); + Description = compilation.GetDescription(schemaType); // sharable directives are only allowed on object types and field definitions Shareable = DirectiveScope.None; Attributes = attributes; diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Models/ModuleOptions.cs b/src/HotChocolate/Core/src/Types.Analyzers/Models/ModuleOptions.cs index 68c0b5c47e7..d867c2749db 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Models/ModuleOptions.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Models/ModuleOptions.cs @@ -7,5 +7,6 @@ public enum ModuleOptions RegisterTypes = 1, RegisterDataLoader = 2, IncludeInternalMembers = 4, - Disabled = 8 + DisableXmlDocumentation = 8, + Disabled = 16 } diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Models/ObjectTypeInfo.cs b/src/HotChocolate/Core/src/Types.Analyzers/Models/ObjectTypeInfo.cs index eea8fcea91a..ea469792fa7 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Models/ObjectTypeInfo.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Models/ObjectTypeInfo.cs @@ -10,6 +10,7 @@ public sealed class ObjectTypeInfo , IOutputTypeInfo { public ObjectTypeInfo( + Compilation compilation, INamedTypeSymbol schemaType, INamedTypeSymbol runtimeType, Resolver? nodeResolver, @@ -24,7 +25,7 @@ public ObjectTypeInfo( NodeResolver = nodeResolver; ClassDeclaration = classDeclarationSyntax; Resolvers = resolvers; - Description = schemaType.GetDescription(); + Description = compilation.GetDescription(schemaType); Attributes = attributes; Shareable = attributes.GetShareableScope(); Inaccessible = attributes.GetInaccessibleScope(); diff --git a/src/HotChocolate/Core/src/Types.Analyzers/Models/RootTypeInfo.cs b/src/HotChocolate/Core/src/Types.Analyzers/Models/RootTypeInfo.cs index 8868c81a22b..22db740b8bd 100644 --- a/src/HotChocolate/Core/src/Types.Analyzers/Models/RootTypeInfo.cs +++ b/src/HotChocolate/Core/src/Types.Analyzers/Models/RootTypeInfo.cs @@ -10,6 +10,7 @@ public sealed class RootTypeInfo , IOutputTypeInfo { public RootTypeInfo( + Compilation compilation, INamedTypeSymbol schemaType, OperationType operationType, ClassDeclarationSyntax classDeclarationSyntax, @@ -21,7 +22,7 @@ public RootTypeInfo( SchemaTypeFullName = schemaType.ToDisplayString(); ClassDeclaration = classDeclarationSyntax; Resolvers = resolvers; - Description = schemaType.GetDescription(); + Description = compilation.GetDescription(schemaType); Attributes = attributes; Shareable = attributes.GetShareableScope(); Inaccessible = attributes.GetInaccessibleScope(); diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/ObjectTypeTests.DisableXmlDocumentation.cs b/src/HotChocolate/Core/test/Types.Analyzers.Tests/ObjectTypeTests.DisableXmlDocumentation.cs new file mode 100644 index 00000000000..8f299400641 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/ObjectTypeTests.DisableXmlDocumentation.cs @@ -0,0 +1,106 @@ +using System.Text.RegularExpressions; + +namespace HotChocolate.Types; + +public partial class ObjectTypeDisableXmlDocumentationTests +{ + private static readonly Regex s_description = DescriptionExtractorRegex(); + + [Fact] + public void XmlDocumentation_Is_Suppressed_When_DisableXmlDocumentation_Is_Set() + { + var snapshot = + TestHelper.GetGeneratedSourceSnapshot( + """ + using System; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using HotChocolate; + using HotChocolate.Types; + + [assembly: Module("Test", ModuleOptions.Default | ModuleOptions.DisableXmlDocumentation)] + + namespace TestNamespace; + + [QueryType] + internal static partial class Query + { + /// + /// This should NOT appear in the schema. + /// + public static string GetUser() => "User"; + } + """); + + var content = snapshot.Match(); + var matches = s_description.Matches(content); + Assert.Empty(matches); + } + + [Fact] + public void GraphQLDescription_Attribute_Still_Works_When_DisableXmlDocumentation_Is_Set() + { + var snapshot = + TestHelper.GetGeneratedSourceSnapshot( + """ + using System; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using HotChocolate; + using HotChocolate.Types; + + [assembly: Module("Test", ModuleOptions.Default | ModuleOptions.DisableXmlDocumentation)] + + namespace TestNamespace; + + [QueryType] + internal static partial class Query + { + /// + /// This should NOT appear in the schema. + /// + [GraphQLDescription("Explicit description")] + public static string GetUser() => "User"; + } + """); + + var content = snapshot.Match(); + var emitted = s_description.Matches(content).Single().Groups; + Assert.Equal("Explicit description", emitted[1].Value); + } + + [Fact] + public void XmlDocumentation_Is_Emitted_When_DisableXmlDocumentation_Is_Not_Set() + { + var snapshot = + TestHelper.GetGeneratedSourceSnapshot( + """ + using System; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using HotChocolate; + using HotChocolate.Types; + + namespace TestNamespace; + + [QueryType] + internal static partial class Query + { + /// + /// User description from XML doc. + /// + public static string GetUser() => "User"; + } + """); + + var content = snapshot.Match(); + var emitted = s_description.Matches(content).Single().Groups; + Assert.Equal("User description from XML doc.", emitted[1].Value); + } + + [GeneratedRegex("configuration.Description = \"(.*)\";")] + private static partial Regex DescriptionExtractorRegex(); +} diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.GraphQLDescription_Attribute_Still_Works_When_DisableXmlDocumentation_Is_Set.snap b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.GraphQLDescription_Attribute_Still_Works_When_DisableXmlDocumentation_Is_Set.snap new file mode 100644 index 00000000000..b4ee12b5b55 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.GraphQLDescription_Attribute_Still_Works_When_DisableXmlDocumentation_Is_Set.snap @@ -0,0 +1,115 @@ +HotChocolateTypeModule.735550c.g.cs +--------------- +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTest(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.Query", + global::HotChocolate.Types.OperationTypeNames.Query, + () => global::TestNamespace.Query.Initialize)); + builder.ConfigureSchema( + b => b.TryAddRootType( + () => new global::HotChocolate.Types.ObjectType( + d => d.Name(global::HotChocolate.Types.OperationTypeNames.Query)), + HotChocolate.Language.OperationType.Query)); + return builder; + } + } +} + +--------------- + +Query.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs +--------------- +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + internal static partial class Query + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + var extension = descriptor.Extend(); + var configuration = extension.Configuration; + var thisType = typeof(global::TestNamespace.Query); + var bindingResolver = extension.Context.ParameterBindingResolver; + var resolvers = new __Resolvers(); + + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + extension.Context, + descriptor, + null, + new global::HotChocolate.Types.QueryTypeAttribute()); + configuration.ConfigurationsAreApplied = true; + + var naming = descriptor.Extend().Context.Naming; + + descriptor + .Field(naming.GetMemberName("User", global::HotChocolate.Types.MemberKind.ObjectField)) + .ExtendWith(static (field, context) => + { + var configuration = field.Configuration; + var typeInspector = field.Context.TypeInspector; + var bindingResolver = field.Context.ParameterBindingResolver; + var naming = field.Context.Naming; + + configuration.Description = "Explicit description"; + configuration.Type = global::HotChocolate.Types.Descriptors.TypeReference.Create( + typeInspector.GetTypeRef(typeof(string), HotChocolate.Types.TypeContext.Output), + new global::HotChocolate.Language.NonNullTypeNode(new global::HotChocolate.Language.NamedTypeNode("string"))); + configuration.ResultType = typeof(string); + + configuration.SetSourceGeneratorFlags(); + + configuration.Resolvers = context.Resolvers.GetUser(); + }, + (Resolvers: resolvers, ThisType: thisType)); + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + public HotChocolate.Resolvers.FieldResolverDelegates GetUser() + { + return new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: GetUser); + } + + private global::System.Object? GetUser(global::HotChocolate.Resolvers.IResolverContext context) + { + var result = global::TestNamespace.Query.GetUser(); + return result; + } + } + } +} + + +--------------- diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.XmlDocumentation_Is_Emitted_When_DisableXmlDocumentation_Is_Not_Set.snap b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.XmlDocumentation_Is_Emitted_When_DisableXmlDocumentation_Is_Not_Set.snap new file mode 100644 index 00000000000..9f7b017204d --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.XmlDocumentation_Is_Emitted_When_DisableXmlDocumentation_Is_Not_Set.snap @@ -0,0 +1,115 @@ +HotChocolateTypeModule.735550c.g.cs +--------------- +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestsTypesRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.Query", + global::HotChocolate.Types.OperationTypeNames.Query, + () => global::TestNamespace.Query.Initialize)); + builder.ConfigureSchema( + b => b.TryAddRootType( + () => new global::HotChocolate.Types.ObjectType( + d => d.Name(global::HotChocolate.Types.OperationTypeNames.Query)), + HotChocolate.Language.OperationType.Query)); + return builder; + } + } +} + +--------------- + +Query.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs +--------------- +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + internal static partial class Query + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + var extension = descriptor.Extend(); + var configuration = extension.Configuration; + var thisType = typeof(global::TestNamespace.Query); + var bindingResolver = extension.Context.ParameterBindingResolver; + var resolvers = new __Resolvers(); + + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + extension.Context, + descriptor, + null, + new global::HotChocolate.Types.QueryTypeAttribute()); + configuration.ConfigurationsAreApplied = true; + + var naming = descriptor.Extend().Context.Naming; + + descriptor + .Field(naming.GetMemberName("User", global::HotChocolate.Types.MemberKind.ObjectField)) + .ExtendWith(static (field, context) => + { + var configuration = field.Configuration; + var typeInspector = field.Context.TypeInspector; + var bindingResolver = field.Context.ParameterBindingResolver; + var naming = field.Context.Naming; + + configuration.Description = "User description from XML doc."; + configuration.Type = global::HotChocolate.Types.Descriptors.TypeReference.Create( + typeInspector.GetTypeRef(typeof(string), HotChocolate.Types.TypeContext.Output), + new global::HotChocolate.Language.NonNullTypeNode(new global::HotChocolate.Language.NamedTypeNode("string"))); + configuration.ResultType = typeof(string); + + configuration.SetSourceGeneratorFlags(); + + configuration.Resolvers = context.Resolvers.GetUser(); + }, + (Resolvers: resolvers, ThisType: thisType)); + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + public HotChocolate.Resolvers.FieldResolverDelegates GetUser() + { + return new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: GetUser); + } + + private global::System.Object? GetUser(global::HotChocolate.Resolvers.IResolverContext context) + { + var result = global::TestNamespace.Query.GetUser(); + return result; + } + } + } +} + + +--------------- diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.XmlDocumentation_Is_Suppressed_When_DisableXmlDocumentation_Is_Set.snap b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.XmlDocumentation_Is_Suppressed_When_DisableXmlDocumentation_Is_Set.snap new file mode 100644 index 00000000000..c6139ce4a49 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/ObjectTypeDisableXmlDocumentationTests.XmlDocumentation_Is_Suppressed_When_DisableXmlDocumentation_Is_Set.snap @@ -0,0 +1,114 @@ +HotChocolateTypeModule.735550c.g.cs +--------------- +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static partial class TestRequestExecutorBuilderExtensions + { + public static IRequestExecutorBuilder AddTest(this IRequestExecutorBuilder builder) + { + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd( + "Tests::TestNamespace.Query", + global::HotChocolate.Types.OperationTypeNames.Query, + () => global::TestNamespace.Query.Initialize)); + builder.ConfigureSchema( + b => b.TryAddRootType( + () => new global::HotChocolate.Types.ObjectType( + d => d.Name(global::HotChocolate.Types.OperationTypeNames.Query)), + HotChocolate.Language.OperationType.Query)); + return builder; + } + } +} + +--------------- + +Query.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs +--------------- +// + +#nullable enable +#pragma warning disable + +using System; +using System.Runtime.CompilerServices; +using HotChocolate; +using HotChocolate.Types; +using HotChocolate.Execution.Configuration; +using Microsoft.Extensions.DependencyInjection; +using HotChocolate.Internal; + +namespace TestNamespace +{ + internal static partial class Query + { + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor descriptor) + { + var extension = descriptor.Extend(); + var configuration = extension.Configuration; + var thisType = typeof(global::TestNamespace.Query); + var bindingResolver = extension.Context.ParameterBindingResolver; + var resolvers = new __Resolvers(); + + HotChocolate.Internal.ConfigurationHelper.ApplyConfiguration( + extension.Context, + descriptor, + null, + new global::HotChocolate.Types.QueryTypeAttribute()); + configuration.ConfigurationsAreApplied = true; + + var naming = descriptor.Extend().Context.Naming; + + descriptor + .Field(naming.GetMemberName("User", global::HotChocolate.Types.MemberKind.ObjectField)) + .ExtendWith(static (field, context) => + { + var configuration = field.Configuration; + var typeInspector = field.Context.TypeInspector; + var bindingResolver = field.Context.ParameterBindingResolver; + var naming = field.Context.Naming; + + configuration.Type = global::HotChocolate.Types.Descriptors.TypeReference.Create( + typeInspector.GetTypeRef(typeof(string), HotChocolate.Types.TypeContext.Output), + new global::HotChocolate.Language.NonNullTypeNode(new global::HotChocolate.Language.NamedTypeNode("string"))); + configuration.ResultType = typeof(string); + + configuration.SetSourceGeneratorFlags(); + + configuration.Resolvers = context.Resolvers.GetUser(); + }, + (Resolvers: resolvers, ThisType: thisType)); + + Configure(descriptor); + } + + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor descriptor); + + private sealed class __Resolvers + { + public HotChocolate.Resolvers.FieldResolverDelegates GetUser() + { + return new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: GetUser); + } + + private global::System.Object? GetUser(global::HotChocolate.Resolvers.IResolverContext context) + { + var result = global::TestNamespace.Query.GetUser(); + return result; + } + } + } +} + + +---------------