Skip to content

Commit b9c1b15

Browse files
hth313xperiandri
authored andcommitted
Fix deserialization of ID type
Deserialization of ID types caused an exception if the field was nullable.
1 parent aeaf698 commit b9c1b15

File tree

3 files changed

+1598
-1
lines changed

3 files changed

+1598
-1
lines changed

tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="AspNetCore/TestSchema.fs" />
7070
<Compile Include="AspNetCore/InvalidMessageTests.fs" />
7171
<Compile Include="AspNetCore/SerializationTests.fs" />
72+
<Compile Include="ResponseJsonTests.fs" />
7273
<Compile Include="Program.fs" />
7374
</ItemGroup>
7475

@@ -81,6 +82,13 @@
8182
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Shared\FSharp.Data.GraphQL.Shared.fsproj" />
8283
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server\FSharp.Data.GraphQL.Server.fsproj" />
8384
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server.AspNetCore\FSharp.Data.GraphQL.Server.AspNetCore.fsproj" />
85+
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Client.DesignTime\FSharp.Data.GraphQL.Client.DesignTime.fsproj" />
8486
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server.Middleware\FSharp.Data.GraphQL.Server.Middleware.fsproj" />
8587
</ItemGroup>
86-
</Project>
88+
</Project>
89+
<ItemGroup Condition="$(OS) == Unix">
90+
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
91+
</ItemGroup>
92+
<Import Project="..\..\netfx.props" />
93+
<Import Project="..\..\.paket\Paket.Restore.targets" />
94+
</Project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module FSharp.Data.GraphQL.Tests.ResponseJsonTests
2+
3+
open System
4+
open Xunit
5+
open Helpers
6+
open FSharp.Data.GraphQL
7+
open FSharp.Data.GraphQL.Client
8+
9+
// Local provider should be able to be created from local introspection json file.
10+
// This schema is adjusted to have some less common type names in order to test them.
11+
type Provider = GraphQLProvider<"introspection-altered-types.json">
12+
13+
14+
[<Fact>]
15+
let ``Should be able to parse nullable ID``() =
16+
let op = Provider.Operation<"""query TestQuery {
17+
hero(id:"1000") {
18+
id,
19+
name,
20+
appearsIn,
21+
homePlanet,
22+
friends {
23+
... on Human {
24+
name,
25+
id
26+
}
27+
... on Droid {
28+
name,
29+
id
30+
}
31+
}
32+
}
33+
}""">
34+
let xop = op()
35+
let result1 = xop.ParseResult("""{
36+
"documentId": 2018203290,
37+
"data": {
38+
"hero": {
39+
"id": "1000",
40+
"__typename": "Human",
41+
"name": "Luke Skywalker",
42+
"appearsIn": [
43+
"NewHope",
44+
"Empire",
45+
"Jedi"
46+
],
47+
"homePlanet": "Tatooine",
48+
"friends": [
49+
{
50+
"name": "Han Solo",
51+
"id": "1002",
52+
"__typename": "Human"
53+
},
54+
{
55+
"name": "Leia Organa",
56+
"id": "1003",
57+
"__typename": "Human"
58+
},
59+
{
60+
"name": "C-3PO",
61+
"id": "2000",
62+
"__typename": "Droid"
63+
},
64+
{
65+
"name": "R2-D2",
66+
"id": "2001",
67+
"__typename": "Droid"
68+
}
69+
]
70+
}
71+
}
72+
}""")
73+
()

0 commit comments

Comments
 (0)