|
| 1 | +# Resolver_Parameter_With_One_Attribute |
| 2 | + |
| 3 | +## HotChocolateTypeModule.735550c.g.cs |
| 4 | + |
| 5 | +```csharp |
| 6 | +// <auto-generated/> |
| 7 | +
|
| 8 | +#nullable enable |
| 9 | +#pragma warning disable |
| 10 | + |
| 11 | +using System; |
| 12 | +using System.Runtime.CompilerServices; |
| 13 | +using HotChocolate; |
| 14 | +using HotChocolate.Types; |
| 15 | +using HotChocolate.Execution.Configuration; |
| 16 | + |
| 17 | +namespace Microsoft.Extensions.DependencyInjection |
| 18 | +{ |
| 19 | + public static partial class TestsTypesRequestExecutorBuilderExtensions |
| 20 | + { |
| 21 | + public static IRequestExecutorBuilder AddTestsTypes(this IRequestExecutorBuilder builder) |
| 22 | + { |
| 23 | + builder.ConfigureDescriptorContext(ctx => ctx.TypeConfiguration.TryAdd<global::TestNamespace.Test>( |
| 24 | + "Tests::TestNamespace.TestType", |
| 25 | + () => global::TestNamespace.TestType.Initialize)); |
| 26 | + builder.AddType<ObjectType<global::TestNamespace.Test>>(); |
| 27 | + return builder; |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +``` |
| 33 | + |
| 34 | +## TestType.WaAdMHmlGJHjtEI4nqY7WA.hc.g.cs |
| 35 | + |
| 36 | +```csharp |
| 37 | +// <auto-generated/> |
| 38 | +
|
| 39 | +#nullable enable |
| 40 | +#pragma warning disable |
| 41 | + |
| 42 | +using System; |
| 43 | +using System.Runtime.CompilerServices; |
| 44 | +using HotChocolate; |
| 45 | +using HotChocolate.Types; |
| 46 | +using HotChocolate.Execution.Configuration; |
| 47 | +using Microsoft.Extensions.DependencyInjection; |
| 48 | +using HotChocolate.Internal; |
| 49 | + |
| 50 | +namespace TestNamespace |
| 51 | +{ |
| 52 | + internal static partial class TestType |
| 53 | + { |
| 54 | + internal static void Initialize(global::HotChocolate.Types.IObjectTypeDescriptor<global::TestNamespace.Test> descriptor) |
| 55 | + { |
| 56 | + var extension = descriptor.Extend(); |
| 57 | + var configuration = extension.Configuration; |
| 58 | + var thisType = typeof(global::TestNamespace.TestType); |
| 59 | + var bindingResolver = extension.Context.ParameterBindingResolver; |
| 60 | + var resolvers = new __Resolvers(bindingResolver); |
| 61 | + |
| 62 | + var naming = descriptor.Extend().Context.Naming; |
| 63 | + |
| 64 | + descriptor |
| 65 | + .Field(naming.GetMemberName("Test", global::HotChocolate.Types.MemberKind.ObjectField)) |
| 66 | + .ExtendWith(static (field, context) => |
| 67 | + { |
| 68 | + var configuration = field.Configuration; |
| 69 | + var typeInspector = field.Context.TypeInspector; |
| 70 | + var bindingResolver = field.Context.ParameterBindingResolver; |
| 71 | + var naming = field.Context.Naming; |
| 72 | + |
| 73 | + configuration.Type = typeInspector.GetTypeRef(typeof(global::HotChocolate.Internal.SourceGeneratedType<global::HotChocolate.Types.NonNullType<global::HotChocolate.Internal.NamedRuntimeType<int>>>), HotChocolate.Types.TypeContext.Output); |
| 74 | + configuration.ResultType = typeof(int); |
| 75 | + |
| 76 | + configuration.SetSourceGeneratorFlags(); |
| 77 | + |
| 78 | + var bindingInfo = field.Context.ParameterBindingResolver; |
| 79 | + var parameter = context.Resolvers.CreateParameterDescriptor_GetTest_test(); |
| 80 | + var parameterInfo = bindingInfo.GetBindingInfo(parameter); |
| 81 | + |
| 82 | + if(parameterInfo.Kind is global::HotChocolate.Internal.ArgumentKind.Argument) |
| 83 | + { |
| 84 | + var argumentConfiguration = new global::HotChocolate.Types.Descriptors.Configurations.ArgumentConfiguration |
| 85 | + { |
| 86 | + Name = naming.GetMemberName("test", global::HotChocolate.Types.MemberKind.Argument), |
| 87 | + Type = typeInspector.GetTypeRef(typeof(global::HotChocolate.Internal.SourceGeneratedType<global::HotChocolate.Types.NonNullType<global::HotChocolate.Internal.NamedRuntimeType<int>>>), HotChocolate.Types.TypeContext.Input), |
| 88 | + RuntimeType = typeof(int) |
| 89 | + }; |
| 90 | + |
| 91 | + var argumentConfigurations = argumentConfiguration.Configurations; |
| 92 | + argumentConfigurations = argumentConfigurations.Add(new global::HotChocolate.Types.Relay.IDAttribute(null)); |
| 93 | + argumentConfiguration.Configurations = argumentConfigurations; |
| 94 | + |
| 95 | + configuration.Arguments.Add(argumentConfiguration); |
| 96 | + } |
| 97 | + |
| 98 | + configuration.Resolvers = context.Resolvers.GetTest(); |
| 99 | + }, |
| 100 | + (Resolvers: resolvers, ThisType: thisType)); |
| 101 | + |
| 102 | + Configure(descriptor); |
| 103 | + } |
| 104 | + |
| 105 | + static partial void Configure(global::HotChocolate.Types.IObjectTypeDescriptor<global::TestNamespace.Test> descriptor); |
| 106 | + |
| 107 | + private sealed class __Resolvers |
| 108 | + { |
| 109 | + private readonly global::HotChocolate.Internal.IParameterBinding _binding_GetTest_test; |
| 110 | + |
| 111 | + public __Resolvers(global::HotChocolate.Resolvers.ParameterBindingResolver bindingResolver) |
| 112 | + { |
| 113 | + _binding_GetTest_test = bindingResolver.GetBinding(CreateParameterDescriptor_GetTest_test()); |
| 114 | + } |
| 115 | + |
| 116 | + public global::HotChocolate.Internal.ParameterDescriptor CreateParameterDescriptor_GetTest_test() |
| 117 | + => new HotChocolate.Internal.ParameterDescriptor( |
| 118 | + "test", |
| 119 | + typeof(int), |
| 120 | + isNullable: false, |
| 121 | + [ |
| 122 | + new global::HotChocolate.Types.Relay.IDAttribute(null) |
| 123 | + ]); |
| 124 | + |
| 125 | + public HotChocolate.Resolvers.FieldResolverDelegates GetTest() |
| 126 | + { |
| 127 | + var isPureResolver = _binding_GetTest_test.IsPure; |
| 128 | + |
| 129 | + return isPureResolver |
| 130 | + ? new global::HotChocolate.Resolvers.FieldResolverDelegates(pureResolver: GetTest) |
| 131 | + : new global::HotChocolate.Resolvers.FieldResolverDelegates(resolver: c => new(GetTest(c))); |
| 132 | + } |
| 133 | + |
| 134 | + private global::System.Object? GetTest(global::HotChocolate.Resolvers.IResolverContext context) |
| 135 | + { |
| 136 | + var args0 = _binding_GetTest_test.Execute<int>(context); |
| 137 | + var result = global::TestNamespace.TestType.GetTest(args0); |
| 138 | + return result; |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | +} |
| 143 | + |
| 144 | + |
| 145 | +``` |
| 146 | + |
0 commit comments