Skip to content

[RFC] Add support for generic IDictionary<string,obj> query inputs - for #472 #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Skip populating Nullable fields with nulls
  • Loading branch information
pkese committed Sep 20, 2024
commit 8c34550e52072963491d06b288b86d3212309dbc
9 changes: 7 additions & 2 deletions src/FSharp.Data.GraphQL.Server/Values.fs
Original file line number Diff line number Diff line change
@@ -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[]) =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And format according to the Fantomas settings

Suggested change
let constructor (args:obj[]) =
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