Product
Hot Chocolate
Version
14.0.0-p.85
Link to minimal reproduction
See zip below
Steps to reproduce
Repro solution: HotChocolateRepro.zip
Repro code for reference:
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
type MyEnum =
| Value1 = 0
| Value2 = 1
type MyType() =
[<HotChocolate.Types.DefaultValue(MyEnum.Value1)>]
member val Enum: MyEnum = MyEnum.Value1 with get, set
type Query() =
member _.Test(arg: MyType) = ""
module Program =
[<EntryPoint>]
let main args =
let builder = WebApplication.CreateBuilder(args)
builder.Services.AddGraphQLServer().AddQueryType<Query>() |> ignore
let app = builder.Build()
app.MapGraphQL() |> ignore
app.Run()
0
What is expected?
type Query {
test(arg: MyTypeInput): String
}
input MyTypeInput {
enum: MyEnum! = VALUE1
}
enum MyEnum {
VALUE1
VALUE2
}
What is actually happening?
type Query {
test(arg: MyTypeInput): String
}
input MyTypeInput {
enum: Int! = 0
}
Relevant log output
No response
Additional context
Strangely enough, the following C# code, which as far as I know is equivalent to the F# code above, does not exhibit the problem, and produces the expected schema:
var builder = WebApplication.CreateBuilder(args);
builder
.Services
.AddGraphQLServer()
.AddQueryType<Query>();
var app = builder.Build();
app.MapGraphQL();
app.Run();
public enum MyEnum
{
Value1 = 0,
Value2 = 1
}
public class MyType
{
[HotChocolate.Types.DefaultValue(MyEnum.Value1)] public MyEnum Enum { get; set; }
}
public class Query
{
public string Test(MyType arg) => "";
}
I tried also adding the GraphQLType(typeof<MyEnum>) attribute to the field. This did not help.
The following workaround seems to work (requires removing the [DefaultValue] attribute from the property to avoid other bugs):
type MyTypeDescriptor() =
inherit InputObjectType<MyType>()
override this.Configure(descriptor: IInputObjectTypeDescriptor<MyType>) : unit =
descriptor.Field("enum").Type(typeof<MyEnum>).DefaultValue(MyEnum.Value1)
|> ignore
// In the builder:
.AddType<MyTypeDescriptor>()
Product
Hot Chocolate
Version
14.0.0-p.85
Link to minimal reproduction
See zip below
Steps to reproduce
Repro solution: HotChocolateRepro.zip
Repro code for reference:
What is expected?
What is actually happening?
Relevant log output
No response
Additional context
Strangely enough, the following C# code, which as far as I know is equivalent to the F# code above, does not exhibit the problem, and produces the expected schema:
I tried also adding the
GraphQLType(typeof<MyEnum>)attribute to the field. This did not help.The following workaround seems to work (requires removing the
[DefaultValue]attribute from the property to avoid other bugs):