Skip to content

Commit

Permalink
Skip populating Nullable fields with nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
pkese committed Sep 20, 2024
1 parent 8cb230d commit 8c34550
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/FSharp.Data.GraphQL.Server/Values.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,19 @@ let rec internal compileByType
{ new Reflection.ParameterInfo() with
member _.Name = f.Name
member _.ParameterType = f.TypeDef.Type
member _.Attributes = Reflection.ParameterAttributes.Optional
member _.Attributes =
match f.TypeDef with
| Nullable _ -> Reflection.ParameterAttributes.Optional
| _ -> Reflection.ParameterAttributes.None
}
|]
let constructor (args:obj[]) =
let o = Activator.CreateInstance(objtype)
let dict = o :?> IDictionary<string, obj>
for fld,arg in Seq.zip objDef.Fields args do
dict.Add(fld.Name, arg)
match arg, fld.TypeDef with
| null, Nullable _ -> () // skip populating Nullable fields with nulls
| _, _ -> dict.Add(fld.Name, arg)
box o
constructor, parameterInfos
else
Expand Down

0 comments on commit 8c34550

Please sign in to comment.