diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj b/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj index 55c630c38..efa954b99 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj @@ -24,6 +24,7 @@ + diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/ResponseJsonTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/ResponseJsonTests.fs new file mode 100644 index 000000000..04fe8fde7 --- /dev/null +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/ResponseJsonTests.fs @@ -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"> + + +[] +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" + } + ] + } + } + }""") + () diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json b/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json index c3fe6fa10..b1803e0f8 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json @@ -971,7 +971,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -998,7 +998,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1025,7 +1025,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1174,7 +1174,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1470,7 +1470,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1521,7 +1521,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1575,7 +1575,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1617,7 +1617,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1750,4 +1750,4 @@ ] } } -} \ No newline at end of file +} diff --git a/tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj b/tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj index f67afae82..63da81ea3 100644 --- a/tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj +++ b/tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj @@ -69,6 +69,7 @@ + @@ -81,6 +82,7 @@ + - \ No newline at end of file +