@@ -603,3 +603,73 @@ let ``Execution handles errors: additional error added and when null returned fr
603603 ensureRequestError result <| fun errors ->
604604 result.DocumentId |> notEquals Unchecked.defaultof< int>
605605 errors |> equals expectedErrors
606+
607+ type PersonWithGuidId =
608+ { Id: Guid
609+ Name: string }
610+
611+ [<Fact>]
612+ let ``Execution handles ID scalar : serializes Guid field via AutoField`` () =
613+ let id1 = Guid.Parse " d6c684d9-aaaa-4e88-bbb2-0bb584f1661d"
614+ let id2 = Guid.Parse " d6c684d9-bbbb-4e88-bbb2-0bb584f1661d"
615+ let people =
616+ [ { Id = id1; Name = " Person A" }
617+ { Id = id2; Name = " Person B" } ]
618+
619+ let PersonType =
620+ Define.Object< PersonWithGuidId>(
621+ " Person" ,
622+ [ Define.AutoField( " id" , IDType)
623+ Define.AutoField( " name" , StringType) ])
624+
625+ let QueryRoot =
626+ Define.Object( " Query" ,
627+ [ Define.Field( " people" , ListOf PersonType, fun _ () -> people) ])
628+
629+ let schema = Schema( query = QueryRoot)
630+ let executor = Executor( schema)
631+
632+ let result = sync <| executor.AsyncExecute( " {people{id name}}" , getMockInputContext)
633+ let expected =
634+ NameValueLookup.ofList [
635+ " people" , upcast [
636+ box <| NameValueLookup.ofList [ " id" , box ( string id1); " name" , box " Person A" ]
637+ box <| NameValueLookup.ofList [ " id" , box ( string id2); " name" , box " Person B" ]
638+ ]
639+ ]
640+ ensureDirect result <| fun data errors ->
641+ empty errors
642+ data |> equals ( upcast expected)
643+
644+ [<Fact>]
645+ let ``Execution handles ID scalar : serializes Guid field via explicit Field resolve`` () =
646+ let id1 = Guid.Parse " d6c684d9-aaaa-4e88-bbb2-0bb584f1661d"
647+ let id2 = Guid.Parse " d6c684d9-bbbb-4e88-bbb2-0bb584f1661d"
648+ let people =
649+ [ { Id = id1; Name = " Person A" }
650+ { Id = id2; Name = " Person B" } ]
651+
652+ let PersonType =
653+ Define.Object< PersonWithGuidId>(
654+ " Person" ,
655+ [ Define.Field( " id" , IDType, fun _ ( p : PersonWithGuidId ) -> string p.Id)
656+ Define.AutoField( " name" , StringType) ])
657+
658+ let QueryRoot =
659+ Define.Object( " Query" ,
660+ [ Define.Field( " people" , ListOf PersonType, fun _ () -> people) ])
661+
662+ let schema = Schema( query = QueryRoot)
663+ let executor = Executor( schema)
664+
665+ let result = sync <| executor.AsyncExecute( " {people{id name}}" , getMockInputContext)
666+ let expected =
667+ NameValueLookup.ofList [
668+ " people" , upcast [
669+ box <| NameValueLookup.ofList [ " id" , box ( string id1); " name" , box " Person A" ]
670+ box <| NameValueLookup.ofList [ " id" , box ( string id2); " name" , box " Person B" ]
671+ ]
672+ ]
673+ ensureDirect result <| fun data errors ->
674+ empty errors
675+ data |> equals ( upcast expected)
0 commit comments