cmeeren / FSharp.HotChocolate

Support for F# types and nullability in HotChocolate
MIT License
7 stars 1 forks source link

Support option-wrapped (nullable) lists in directive arguments (directive POCO fields) #22

Open cmeeren opened 4 days ago

cmeeren commented 4 days ago

If a directive POCO has an Option<_>-wrapped list property, such as string array option, it fails with this error:

The directive arguments have invalid values: 'The list runtime value of [String!] must implement IEnumerable or IList but is of the type Microsoft.FSharp.Core.FSharpOption`1[[System.String[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].' at /my/optionOfArrayOfString. (.Nullability.MyDirectiveDescriptor)

A similar error was solved for object fields by adding a formatter that unwraps option values. However, this does not seem to be possible for directive arguments. The only formatter I can find for DirectiveArgumentDefinition is the Formatters property. I tried to add a suitable IInputValueFormatter to that collection, but it's never called.

@michaelstaib, do you have any ideas on how I can work around this issue?