Skip to content
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

Fixed ID type deserialization #410

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<Compile Include="Helpers.fs" />
<Compile Include="LocalProviderTests.fs" />
<Compile Include="LocalProviderWithOptionalParametersOnlyTests.fs" />
<Compile Include="ResponseJsonTests.fs" />
<Compile Include="SwapiLocalProviderTests.fs" />
<Compile Include="SwapiRemoteProviderTests.fs" />
</ItemGroup>
Expand Down
73 changes: 73 additions & 0 deletions tests/FSharp.Data.GraphQL.IntegrationTests/ResponseJsonTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module FSharp.Data.GraphQL.IntegrationTests.ResponseJsonTests

open System
open Xunit
open Helpers
open FSharp.Data.GraphQL
open FSharp.Data.GraphQL.Client

// Local provider should be able to be created from local introspection json file.
// This schema is adjusted to have some less common type names in order to test them.
type Provider = GraphQLProvider<"introspection.json">


[<Fact>]
let ``Should be able to parse nullable ID``() =
let op = Provider.Operation<"""query TestQuery {
hero(id:"1000") {
id,
name,
appearsIn,
homePlanet,
friends {
... on Human {
name,
id
}
... on Droid {
name,
id
}
}
}
}""">
let xop = op()
let result1 = xop.ParseResult("""{
"documentId": 2018203290,
"data": {
"hero": {
"id": "1000",
"__typename": "Human",
"name": "Luke Skywalker",
"appearsIn": [
"NewHope",
"Empire",
"Jedi"
],
"homePlanet": "Tatooine",
"friends": [
{
"name": "Han Solo",
"id": "1002",
"__typename": "Human"
},
{
"name": "Leia Organa",
"id": "1003",
"__typename": "Human"
},
{
"name": "C-3PO",
"id": "2000",
"__typename": "Droid"
},
{
"name": "R2-D2",
"id": "2001",
"__typename": "Droid"
}
]
}
}
}""")
()
18 changes: 9 additions & 9 deletions tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand All @@ -998,7 +998,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand All @@ -1025,7 +1025,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand Down Expand Up @@ -1174,7 +1174,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand Down Expand Up @@ -1470,7 +1470,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand Down Expand Up @@ -1521,7 +1521,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand Down Expand Up @@ -1575,7 +1575,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand Down Expand Up @@ -1617,7 +1617,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand Down Expand Up @@ -1750,4 +1750,4 @@
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="AspNetCore/TestSchema.fs" />
<Compile Include="AspNetCore/InvalidMessageTests.fs" />
<Compile Include="AspNetCore/SerializationTests.fs" />
<Compile Include="ResponseJsonTests.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

Expand All @@ -81,6 +82,7 @@
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Shared\FSharp.Data.GraphQL.Shared.fsproj" />
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server\FSharp.Data.GraphQL.Server.fsproj" />
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server.AspNetCore\FSharp.Data.GraphQL.Server.AspNetCore.fsproj" />
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Client.DesignTime\FSharp.Data.GraphQL.Client.DesignTime.fsproj" />
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server.Middleware\FSharp.Data.GraphQL.Server.Middleware.fsproj" />
</ItemGroup>
</Project>
</Project>
Loading