@@ -45,6 +45,7 @@ type TestNestedInput = {
4545 na: TestInput option
4646 nb: string
4747}
48+
4849let TestNestedInputObject =
4950 Define.InputObject< TestNestedInput>(
5051 name = " TestNestedInputObject" ,
@@ -53,6 +54,21 @@ let TestNestedInputObject =
5354 Define.Input( " nb" , String)
5455 ])
5556
57+ type TestRecusiveInput = {
58+ ra: TestRecusiveInput option
59+ rb: string
60+ }
61+
62+ #nowarn " 40"
63+ let rec TestRecursiveInputObject =
64+ Define.InputObject< TestRecusiveInput>(
65+ name = " TestRecusiveInput" ,
66+ fieldsFn =
67+ fun () -> [
68+ Define.Input( " ra" , Nullable TestRecursiveInputObject)
69+ Define.Input( " rb" , String)]
70+ )
71+
5672let stringifyArg name ( ctx : ResolveFieldContext ) () =
5773 let arg = ctx.TryArg name |> Option.toObj
5874 toJson arg
@@ -79,6 +95,7 @@ let TestType =
7995 Define.Field( " fieldWithNonNullableStringInput" , String, " " , [ Define.Input( " input" , String) ], stringifyInput)
8096 Define.Field( " fieldWithDefaultArgumentValue" , String, " " , [ Define.Input( " input" , Nullable String, Some " hello world" ) ], stringifyInput)
8197 Define.Field( " fieldWithNestedInputObject" , String, " " , [ Define.Input( " input" , TestNestedInputObject, { na = None; nb = " hello world" }) ], stringifyInput)
98+ Define.Field( " fieldWithRecursiveInputObject" , String, " " , [ Define.Input( " input" , TestRecursiveInputObject, { ra = None; rb = " hello world" }) ], stringifyInput)
8299 Define.Field( " fieldWithEnumInput" , String, " " , [ Define.Input( " input" , EnumTestType) ], stringifyInput)
83100 Define.Field( " fieldWithNullableEnumInput" , String, " " , [ Define.Input( " input" , Nullable EnumTestType) ], stringifyInput)
84101 Define.Field( " list" , String, " " , [ Define.Input( " input" , Nullable( ListOf ( Nullable String))) ], stringifyInput)
@@ -123,7 +140,7 @@ let ``Execute handles objects and nullability using inline structs and doesn't u
123140 | _ -> fail " Expected Direct GQResponse"
124141
125142[<Fact>]
126- let ``Execute handles objects and nullability using inline structs and proprely coerces complex scalar types`` () =
143+ let ``Execute handles objects and nullability using inline structs and properly coerces complex scalar types`` () =
127144 let ast = parse """ { fieldWithObjectInput(input: {c: "foo", d: "SerializedValue"}) }"""
128145 let actual = sync <| Executor( schema) .AsyncExecute( ast)
129146 let expected = NameValueLookup.ofList [ " fieldWithObjectInput" , upcast """ {"a":null,"b":null,"c":"foo","d":"DeserializedValue","e":null}""" ]
@@ -328,6 +345,28 @@ let ``Execute handles non-nullable scalars and passes along null for non-nullabl
328345 data.[ " data" ] |> equals ( upcast expected)
329346 | _ -> fail " Expected Direct GQResponse"
330347
348+ [<Fact>]
349+ let ``Execute handles nested input objects and nullability using inline structs and properly coerces complex scalar types`` () =
350+ let ast = parse """ { fieldWithNestedInputObject(input: {na:{c:"c"},nb:"b"})}"""
351+ let actual = sync <| Executor( schema) .AsyncExecute( ast)
352+ let expected = NameValueLookup.ofList [ " fieldWithNestedInputObject" , upcast """ {"na":{"a":null,"b":null,"c":"c","d":null,"e":null},"nb":"b"}""" ]
353+ match actual with
354+ | Direct( data, errors) ->
355+ empty errors
356+ data.[ " data" ] |> equals ( upcast expected)
357+ | _ -> fail " Expected Direct GQResponse"
358+
359+ [<Fact>]
360+ let ``Execute handles recursive input objects and nullability using inline structs and properly coerces complex scalar types`` () =
361+ let ast = parse """ { fieldWithRecursiveInputObject(input: {ra:{rb:"bb"},rb:"b"})}"""
362+ let actual = sync <| Executor( schema) .AsyncExecute( ast)
363+ let expected = NameValueLookup.ofList [ " fieldWithRecursiveInputObject" , upcast """ {"ra":{"ra":null,"rb":"bb"},"rb":"b"}""" ]
364+ match actual with
365+ | Direct( data, errors) ->
366+ empty errors
367+ data.[ " data" ] |> equals ( upcast expected)
368+ | _ -> fail " Expected Direct GQResponse"
369+
331370[<Fact>]
332371let ``Execute handles list inputs and nullability and allows lists to be null`` () =
333372 let ast = parse """ query q($input: [String]) {
0 commit comments