Exception when using enum in schema first
Object of type 'System.String' cannot be converted to type '....ProductType'. at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast) at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig) at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) at HotChocolate.Types.InputField.SetValue(Object obj, Object value) at HotChocolate.Utilities.ObjectValueToInputObjectConverter.VisitObjectField(ObjectFieldNode node, ConverterContext context) at HotChocolate.Utilities.ObjectValueToInputObjectConverter.VisitObjectValue(ObjectValueNode node, ConverterContext context) at HotChocolate.Utilities.ObjectValueToInputObjectConverter.Convert(ObjectValueNode from, InputObjectType to) at HotChocolate.Execution.ArgumentValueBuilder.CoerceArgumentValue(String argumentName, IInputType argumentType, IValueNode defaultValue, IVariableCollection variables, Dictionary
2 argumentValues) at HotChocolate.Execution.ArgumentValueBuilder.CoerceArgumentValues(FieldSelection fieldSelection, IVariableCollection variables) at HotChocolate.Execution.ResolverContext..ctor(IExecutionContext executionContext, ResolverTask resolverTask, CancellationToken requestAborted) at HotChocolate.Execution.ResolverTask..ctor(IExecutionContext executionContext, ObjectType objectType, FieldSelection fieldSelection, Path path, IImmutableStack1 source, OrderedDictionary result) at HotChocolate.Execution.ExecutionStrategyBase.CreateRootResolverTasks(IExecutionContext executionContext, OrderedDictionary result)+MoveNext() at HotChocolate.Execution.MutationExecutionStrategy.ExecuteResolverBatchSeriallyAsync(IExecutionContext executionContext, IEnumerable`1 currentBatch, BatchOperationHandler batchOperationHandler, CancellationToken cancellationToken) at HotChocolate.Execution.MutationExecutionStrategy.ExecuteMutationAsync(IExecutionContext executionContext, CancellationToken cancellationToken) at HotChocolate.Execution.ExecuteOperationMiddleware.InvokeAsync(IQueryContext context) at HotChocolate.Execution.ExceptionMiddleware.InvokeAsync(IQueryContext context)
Usage in query type: SERVICE
Fixed with #484
Enum works if used directly as query input field but still fails when used as field in input object.
0.7.0-preview.30
using HotChocolate;
using HotChocolate.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace webapi
{
public enum SomeEnum {
EnumVal1
}
public class InputObj
{
public SomeEnum EnumVal { get; set; }
}
public class Mutation
{
public bool DoesNotWork(InputObj input) => true;
public bool DoesWork(SomeEnum input) => true;
}
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddGraphQL(sp => Schema.Create(@"
enum SomeEnum {
ENUMVAL1
}
input InputObj {
enumVal: SomeEnum!
}
type Mutation {
doesNotWork(input: InputObj!): Boolean!
doesWork(input: SomeEnum!): Boolean!
}
", c => {
c.BindType<Mutation>();
c.BindType<InputObj>();
}));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseGraphQL("/graphql");
app.UseGraphiQL();
}
}
}
I will write another test ... for this one.
Fixed with #489