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 5d7e2d00..37391d6b 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj @@ -19,6 +19,7 @@ + PreserveNewest @@ -30,6 +31,7 @@ + diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/ResponseJsonTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/ResponseJsonTests.fs new file mode 100644 index 00000000..04fe8fde --- /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 a961111f..011dd95d 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json @@ -981,7 +981,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1008,7 +1008,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1035,7 +1035,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1184,7 +1184,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1480,7 +1480,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1531,7 +1531,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1601,7 +1601,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1688,7 +1688,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, @@ -1862,4 +1862,4 @@ ] } } -} \ No newline at end of file +}