Closed cmeeren closed 1 week ago
The following code defines a directive with a nullable (option-wrapped) argument MyValue:
MyValue
open System open HotChocolate.Types type MyDirective = { MyValue: string option } type MyDirectiveDescriptor() = inherit DirectiveType<MyDirective>() override this.Configure(descriptor: IDirectiveTypeDescriptor<MyDirective>) : unit = descriptor.Location(DirectiveLocation.FieldDefinition) |> ignore [<AttributeUsage(AttributeTargets.Property ||| AttributeTargets.Method)>] type MyDirectiveAttribute(value: string) = inherit ObjectFieldDescriptorAttribute() override this.OnConfigure(_context, descriptor, _member) = descriptor.Directive({ MyValue = Some value }) |> ignore
Usage:
type MyType = { [<MyDirective("myValue")>] MyField: int }
When enabling the new F# 9 nullable reference types, the myValue directive argument becomes String! instead of String.
myValue
String!
String
Furthermore, using GraphQLType as shown below will make it a nullable String again:
GraphQLType
[<GraphQLType(typeof<StringType>)>] MyValue: string option
The two points above indicate that FSharp.HotChocolate is currently not applying nullability to directive arguments.
The following code defines a directive with a nullable (option-wrapped) argument
MyValue
:Usage:
When enabling the new F# 9 nullable reference types, the
myValue
directive argument becomesString!
instead ofString
.Furthermore, using
GraphQLType
as shown below will make it a nullableString
again:The two points above indicate that FSharp.HotChocolate is currently not applying nullability to directive arguments.