diff --git a/FSharp.Data.GraphQL.Integration.slnx b/FSharp.Data.GraphQL.Integration.slnx index ebd077769..b8e081034 100644 --- a/FSharp.Data.GraphQL.Integration.slnx +++ b/FSharp.Data.GraphQL.Integration.slnx @@ -4,6 +4,9 @@ + + + @@ -12,7 +15,9 @@ + + diff --git a/Packages.props b/Packages.props index 7d3b9582b..323f603f2 100644 --- a/Packages.props +++ b/Packages.props @@ -76,6 +76,7 @@ + diff --git a/build/Program.fs b/build/Program.fs index 22bbb133c..f23d68415 100644 --- a/build/Program.fs +++ b/build/Program.fs @@ -2,8 +2,6 @@ module Program open System open System.IO -open System.Net.Http -open System.Text.Json open Fake.Core open Fake.Core.TargetOperators @@ -123,26 +121,6 @@ let runTests (project : string) (args : string) = |> _.WithCommon(DotNetCli.setVersion)) project -let starWarsServerStream = StreamRef.Empty - -let [] StartStarWarsServerTarget = "StartStarWarsServer" -Target.create StartStarWarsServerTarget <| fun _ -> - Target.activateFinal "StopStarWarsServer" - - let project = - "samples" - "star-wars-api" - "star-wars-api.fsproj" - - startGraphQLServer project 8086 starWarsServerStream - -let [] StopStarWarsServerTarget = "StopStarWarsServer" -Target.createFinal StopStarWarsServerTarget <| fun _ -> - try - starWarsServerStream.Value.Write ([| 0uy |], 0, 1) - with e -> - printfn "%s" e.Message - let integrationTestServerProjectPath = "tests" "FSharp.Data.GraphQL.IntegrationTests.Server" @@ -179,58 +157,35 @@ Target.createFinal StopIntegrationServerTarget <| fun _ -> with e -> printfn "%s" e.Message -let [] UpdateIntrospectionFileTarget = "UpdateIntrospectionFile" -Target.create UpdateIntrospectionFileTarget <| fun _ -> - let client = new HttpClient () - (task { - let! result = client.GetAsync ("http://localhost:8086") - let! contentStream = result.Content.ReadAsStreamAsync () - let! jsonDocument = JsonDocument.ParseAsync contentStream - let file = - new FileStream ("tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json", FileMode.Create, FileAccess.Write, FileShare.None) - let encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping - let jsonWriterOptions = JsonWriterOptions (Indented = true, Encoder = encoder) - let writer = new Utf8JsonWriter (file, jsonWriterOptions) - jsonDocument.WriteTo writer - do! writer.FlushAsync () - do! writer.DisposeAsync () - do! file.DisposeAsync () - result.Dispose () - }) - .Wait () - client.Dispose () - -let unitTestsProjectPath = - "tests" - "FSharp.Data.GraphQL.Tests" - "FSharp.Data.GraphQL.Tests.fsproj" - let integrationTestsProjectPath = "tests" "FSharp.Data.GraphQL.IntegrationTests" "FSharp.Data.GraphQL.IntegrationTests.fsproj" -let [] BuildIntegrationTestsTarget = "BuildIntegrationTests" -Target.create BuildIntegrationTestsTarget <| fun _ -> +let [] UpdateIntrospectionFileTarget = "UpdateIntrospectionFile" +Target.create UpdateIntrospectionFileTarget <| fun _ -> integrationTestsProjectPath - |> DotNet.build (fun options -> { + |> DotNet.test (fun options -> { options with + Framework = Some DotNetMoniker Configuration = configuration + Common = { DotNetCli.setVersion options.Common with CustomParams = Some "--filter FullyQualifiedName~IntrospectionUpdateTests" } MSBuildParams = { options.MSBuildParams with DisableInternalBinLog = true + Verbosity = Some Normal } - Common = DotNetCli.setVersion options.Common }) +let unitTestsProjectPath = + "tests" + "FSharp.Data.GraphQL.Tests" + "FSharp.Data.GraphQL.Tests.fsproj" + let [] RunUnitTestsTarget = "RunUnitTests" Target.create RunUnitTestsTarget <| fun _ -> runTests unitTestsProjectPath "" -let [] RunIntegrationTestsTarget = "RunIntegrationTests" -Target.create RunIntegrationTestsTarget <| fun _ -> - runTests integrationTestsProjectPath "" //"--filter Execution=Sync" - let prepareDocGen () = Shell.rm "docs/release-notes.md" Shell.cp "RELEASE_NOTES.md" "docs/RELEASE_NOTES.md" @@ -406,12 +361,7 @@ Target.create "PackAndPush" ignore ==> RestoreTarget ==> BuildTarget ==> RunUnitTestsTarget -==> StartStarWarsServerTarget -==> BuildIntegrationTestServerTarget -==> StartIntegrationServerTarget ==> UpdateIntrospectionFileTarget -==> BuildIntegrationTestsTarget -==> RunIntegrationTestsTarget ==> "All" =?> (GenerateDocsTarget, Environment.environVar "GITHUB_ACTIONS" = "True") |> ignore diff --git a/samples/star-wars-fabulous-client/StarWars.slnx b/samples/star-wars-fabulous-client/StarWars.slnx index 51d68264a..52cff01ec 100644 --- a/samples/star-wars-fabulous-client/StarWars.slnx +++ b/samples/star-wars-fabulous-client/StarWars.slnx @@ -14,6 +14,12 @@ + + + + + + diff --git a/samples/star-wars-fabulous-client/StarWars/Common.fs b/samples/star-wars-fabulous-client/StarWars/Common.fs index 3974e6c92..1de5ae4e9 100644 --- a/samples/star-wars-fabulous-client/StarWars/Common.fs +++ b/samples/star-wars-fabulous-client/StarWars/Common.fs @@ -5,7 +5,10 @@ open FSharp.Data.GraphQL module Commands = - type GraphQLApi = GraphQLProvider<"http://localhost:8086"> + [] + let IntrospectionPath = "../../../tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json" + + type GraphQLApi = GraphQLProvider let GetCharactersData = GraphQLApi.Operation<"queries/FetchCharacters.graphql">() type Character = GraphQLApi.Operations.FetchCharacters.Types.CharactersFields.Character diff --git a/samples/star-wars-fabulous-client/StarWars/StarWars.fsproj b/samples/star-wars-fabulous-client/StarWars/StarWars.fsproj index d972d6d59..4769849ad 100644 --- a/samples/star-wars-fabulous-client/StarWars/StarWars.fsproj +++ b/samples/star-wars-fabulous-client/StarWars/StarWars.fsproj @@ -4,7 +4,7 @@ false - + @@ -18,16 +18,16 @@ - - - - - - - - + + + + + + + + - \ No newline at end of file + 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 f133dee2a..5d7e2d004 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj @@ -7,6 +7,7 @@ + @@ -15,6 +16,7 @@ + @@ -22,7 +24,9 @@ + + @@ -30,16 +34,19 @@ + + + + + - ..\..\src\FSharp.Data.GraphQL.Client\bin\Debug\netstandard2.0\FSharp.Data.GraphQL.Client.dll - ..\..\src\FSharp.Data.GraphQL.Client\bin\Release\netstandard2.0\FSharp.Data.GraphQL.Client.dll + ..\..\src\FSharp.Data.GraphQL.Client\bin\$(Configuration)\netstandard2.0\FSharp.Data.GraphQL.Client.dll ..\..\bin\FSharp.Data.GraphQL.Client\netstandard2.0\FSharp.Data.GraphQL.Client.dll - ..\..\src\FSharp.Data.GraphQL.Client\bin\Debug\netstandard2.0\FSharp.Data.GraphQL.Shared.dll - ..\..\src\FSharp.Data.GraphQL.Client\bin\Release\netstandard2.0\FSharp.Data.GraphQL.Shared.dll - ..\..\bin\FSharp.Data.GraphQL.Client\netstandard2.0\FSharp.Data.GraphQL.Shared.dll + ..\..\src\FSharp.Data.GraphQL.Shared\bin\$(Configuration)\net10.0\FSharp.Data.GraphQL.Shared.dll + ..\..\bin\FSharp.Data.GraphQL.Shared\net10.0\FSharp.Data.GraphQL.Shared.dll diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/IntrospectionUpdateTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/IntrospectionUpdateTests.fs new file mode 100644 index 000000000..80a23c5ce --- /dev/null +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/IntrospectionUpdateTests.fs @@ -0,0 +1,90 @@ +module FSharp.Data.GraphQL.IntegrationTests.IntrospectionUpdateTests + +open System +open System.IO +open System.Net.Http.Json +open System.Text.Json +open System.Threading +open Xunit + +let introspectionFilePath = + Path.Combine (__SOURCE_DIRECTORY__, "integration-introspection.json") + |> Path.GetFullPath + +let normalizeJsonDocument options (document : JsonDocument) = + use buffer = new MemoryStream () + use writer = new Utf8JsonWriter (buffer, options) + document.WriteTo writer + writer.Flush () + buffer.Seek (0L, SeekOrigin.Begin) |> ignore + JsonDocument.Parse buffer + +let parseAndNormalizeJsonAsync ct options stream = + task { + let! document = JsonDocument.ParseAsync (stream, cancellationToken = ct) + return normalizeJsonDocument options document + } + +let areSchemasEqual (document1 : JsonDocument) (document2 : JsonDocument) = + let schema1 = document1.RootElement.GetProperty("data").GetProperty("__schema") + let schema2 = document2.RootElement.GetProperty("data").GetProperty("__schema") + schema1.GetRawText() = schema2.GetRawText() + +let readDestinationDocumentAsync ct (stream : FileStream) = + task { + try + let! document = JsonDocument.ParseAsync (stream, cancellationToken = ct) + return ValueSome document + with :? JsonException -> + return ValueNone + } + +let updateIntrospectionFileAsync ct sourceStream = + task { + use destinationStream = + new FileStream (introspectionFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read) + + let options = JsonWriterOptions(Indented = true) + let! sourceDocument = parseAndNormalizeJsonAsync ct options sourceStream + destinationStream.Seek (0L, SeekOrigin.Begin) |> ignore + let! destinationDocument = readDestinationDocumentAsync ct destinationStream + + let shouldUpdate = + match destinationDocument with + | ValueNone -> true + | ValueSome document -> not (areSchemasEqual document sourceDocument) + + if shouldUpdate then + destinationStream.Seek (0L, SeekOrigin.Begin) |> ignore + destinationStream.SetLength 0 + use writer = new Utf8JsonWriter (destinationStream, options) + sourceDocument.WriteTo writer + writer.Flush () + + return shouldUpdate + } + +[] +let ``Get GraphQL introspection response returns schema`` () = + task { + use httpClient = TestHosts.createIntegrationHttpClient () + let! response = httpClient.GetFromJsonAsync("/", CancellationToken.None) + let schema = response.GetProperty("data").GetProperty("__schema") + Assert.NotEqual(Unchecked.defaultof, schema) + let hasErrors, _ = response.TryGetProperty "errors" + Assert.False hasErrors + } + +[] +let ``Update integration introspection file when schema changes`` () = + task { + use httpClient = TestHosts.createIntegrationHttpClient () + let! sourceStream = httpClient.GetStreamAsync("/") + let! wasUpdated = updateIntrospectionFileAsync CancellationToken.None sourceStream + Assert.True(File.Exists introspectionFilePath) + if wasUpdated then + let! sourceStreamSecondRun = httpClient.GetStreamAsync("/") + use sourceStreamForVerification = sourceStreamSecondRun + let! wasUpdatedSecondRun = updateIntrospectionFileAsync CancellationToken.None sourceStreamForVerification + Assert.False wasUpdatedSecondRun + } diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderTests.fs index 897364cb1..24944207e 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderTests.fs +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderTests.fs @@ -5,13 +5,14 @@ open System.Threading.Tasks open FSharp.Data.GraphQL open Helpers -let [] ServerUrl = "http://localhost:8085" +let [] IntrospectionPath = "integration-introspection.json" let [] EmptyGuidAsString = "00000000-0000-0000-0000-000000000000" -type Provider = GraphQLProvider +type Provider = GraphQLProvider // type FileProvider = GraphQLProvider -let context = Provider.GetContext(ServerUrl) +let connection = TestHosts.createIntegrationConnection () +let context = Provider.GetContext(serverUrl = TestHosts.integrationServerUrl, connectionFactory = fun () -> connection) type Input = Provider.Types.Input type InputField = Provider.Types.InputField @@ -59,7 +60,7 @@ module SimpleOperation = [] let ``Should be able to execute a query without sending input field``() = - SimpleOperation.operation.Run() + SimpleOperation.operation.Run(context) |> SimpleOperation.validateResult None [] @@ -69,7 +70,7 @@ let ``Should be able to execute a query using context, without sending input fie [] let ``Should be able to execute a query without sending input field asynchronously``() : Task = task { - let! result = SimpleOperation.operation.AsyncRun() + let! result = SimpleOperation.operation.AsyncRun(context) result |> SimpleOperation.validateResult None } @@ -82,7 +83,7 @@ let ``Should be able to execute a query using context, without sending input fie [] let ``Should be able to execute a query sending an empty input field``() = let input = Input() - SimpleOperation.operation.Run(input) + SimpleOperation.operation.Run(context, input) |> SimpleOperation.validateResult (Some input) [] @@ -94,7 +95,7 @@ let ``Should be able to execute a query using context, sending an empty input fi [] let ``Should be able to execute a query without sending an empty input field asynchronously``() : Task = task { let input = Input() - let! result = SimpleOperation.operation.AsyncRun(input) + let! result = SimpleOperation.operation.AsyncRun(context, input) result |> SimpleOperation.validateResult (Some input) } @@ -109,7 +110,7 @@ let ``Should be able to execute a query using context, sending an empty input fi let ``Should be able to execute a query sending an input field with single field``() = let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let input = Input(single) - SimpleOperation.operation.Run(input) + SimpleOperation.operation.Run(context, input) |> SimpleOperation.validateResult (Some input) [] @@ -123,7 +124,7 @@ let ``Should be able to execute a query using context, sending an input field wi let ``Should be able to execute a query without sending an input field with single field asynchronously``() : Task = task { let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let input = Input(single) - let! result = SimpleOperation.operation.AsyncRun(input) + let! result = SimpleOperation.operation.AsyncRun(context, input) result |> SimpleOperation.validateResult (Some input) } @@ -139,7 +140,7 @@ let ``Should be able to execute a query using context, sending an input field wi let ``Should be able to execute a query sending an input field with list field``() = let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(list) - SimpleOperation.operation.Run(input) + SimpleOperation.operation.Run(context, input) |> SimpleOperation.validateResult (Some input) [] @@ -153,7 +154,7 @@ let ``Should be able to execute a query using context, sending an input field wi let ``Should be able to execute a query without sending an input field with list field asynchronously``() : Task = task { let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(list) - let! result = SimpleOperation.operation.AsyncRun(input) + let! result = SimpleOperation.operation.AsyncRun(context, input) result |> SimpleOperation.validateResult (Some input) } @@ -170,7 +171,7 @@ let ``Should be able to execute a query sending an input field with single and l let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(single, list) - SimpleOperation.operation.Run(input) + SimpleOperation.operation.Run(context, input) |> SimpleOperation.validateResult (Some input) [] @@ -186,7 +187,7 @@ let ``Should be able to execute a query without sending an input field with sing let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(single, list) - let! result = SimpleOperation.operation.AsyncRun(input) + let! result = SimpleOperation.operation.AsyncRun(context, input) result |> SimpleOperation.validateResult (Some input) } @@ -221,13 +222,13 @@ module SingleRequiredUploadOperation = [] let ``Should be able to execute a single required upload``() = let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - SingleRequiredUploadOperation.operation.Run(file.MakeUpload()) + SingleRequiredUploadOperation.operation.Run(context, file.MakeUpload()) |> SingleRequiredUploadOperation.validateResult file [] let ``Should be able to execute a single required upload asynchronously``() : Task = task { let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - let! result = SingleRequiredUploadOperation.operation.AsyncRun(file.MakeUpload()) + let! result = SingleRequiredUploadOperation.operation.AsyncRun(context, file.MakeUpload()) result |> SingleRequiredUploadOperation.validateResult file } @@ -256,24 +257,24 @@ module SingleOptionalUploadOperation = [] let ``Should be able to execute a single optional upload by passing a file``() = let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - SingleOptionalUploadOperation.operation.Run(file.MakeUpload()) + SingleOptionalUploadOperation.operation.Run(context, file.MakeUpload()) |> SingleOptionalUploadOperation.validateResult (Some file) [] let ``Should be able to execute a single optional upload by passing a file, asynchronously``() : Task = task { let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - let! result = SingleOptionalUploadOperation.operation.AsyncRun(file.MakeUpload()) + let! result = SingleOptionalUploadOperation.operation.AsyncRun(context, file.MakeUpload()) result |> SingleOptionalUploadOperation.validateResult (Some file) } [] let ``Should be able to execute a single optional upload by not passing a file``() = - SingleOptionalUploadOperation.operation.Run() + SingleOptionalUploadOperation.operation.Run(context) |> SingleOptionalUploadOperation.validateResult None [] let ``Should be able to execute a single optional upload by not passing a file asynchronously``() : Task = task { - let! result = SingleOptionalUploadOperation.operation.AsyncRun() + let! result = SingleOptionalUploadOperation.operation.AsyncRun(context) result |> SingleOptionalUploadOperation.validateResult None } @@ -302,7 +303,7 @@ let ``Should be able to execute a multiple required upload``() = let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - RequiredMultipleUploadOperation.operation.Run(files |> Array.map (fun f -> f.MakeUpload())) + RequiredMultipleUploadOperation.operation.Run(context, files |> Array.map (fun f -> f.MakeUpload())) |> RequiredMultipleUploadOperation.validateResult files [] @@ -310,7 +311,7 @@ let ``Should be able to execute a multiple required upload asynchronously``() : let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - let! result = RequiredMultipleUploadOperation.operation.AsyncRun(files |> Array.map (fun f -> f.MakeUpload())) + let! result = RequiredMultipleUploadOperation.operation.AsyncRun(context, files |> Array.map (fun f -> f.MakeUpload())) result |> RequiredMultipleUploadOperation.validateResult files } @@ -339,7 +340,7 @@ let ``Should be able to execute a multiple upload``() = let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - OptionalMultipleUploadOperation.operation.Run(files |> Array.map (fun f -> f.MakeUpload())) + OptionalMultipleUploadOperation.operation.Run(context, files |> Array.map (fun f -> f.MakeUpload())) |> OptionalMultipleUploadOperation.validateResult (Some files) [] @@ -347,18 +348,18 @@ let ``Should be able to execute a multiple upload asynchronously``() : Task = ta let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - let! result = OptionalMultipleUploadOperation.operation.AsyncRun(files |> Array.map (fun f -> f.MakeUpload())) + let! result = OptionalMultipleUploadOperation.operation.AsyncRun(context, files |> Array.map (fun f -> f.MakeUpload())) result |> OptionalMultipleUploadOperation.validateResult (Some files) } [] let ``Should be able to execute a multiple upload by sending no uploads``() = - OptionalMultipleUploadOperation.operation.Run() + OptionalMultipleUploadOperation.operation.Run(context) |> OptionalMultipleUploadOperation.validateResult None [] let ``Should be able to execute a multiple upload asynchronously by sending no uploads``() : Task = task { - let! result = OptionalMultipleUploadOperation.operation.AsyncRun() + let! result = OptionalMultipleUploadOperation.operation.AsyncRun(context) result |> OptionalMultipleUploadOperation.validateResult None } @@ -387,7 +388,7 @@ let ``Should be able to execute a multiple optional upload``() = let files = [| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - OptionalMultipleOptionalUploadOperation.operation.Run(files |> Array.map (Option.map (fun f -> f.MakeUpload()))) + OptionalMultipleOptionalUploadOperation.operation.Run(context, files |> Array.map (Option.map (fun f -> f.MakeUpload()))) |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) [] @@ -395,18 +396,18 @@ let ``Should be able to execute a multiple optional upload asynchronously``() : let files = [| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(files |> Array.map (Option.map (fun f -> f.MakeUpload()))) + let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(context, files |> Array.map (Option.map (fun f -> f.MakeUpload()))) result |> (OptionalMultipleOptionalUploadOperation.validateResult (Some files)) } [] let ``Should be able to execute a multiple optional upload by sending no uploads``() = - OptionalMultipleOptionalUploadOperation.operation.Run() + OptionalMultipleOptionalUploadOperation.operation.Run(context) |> OptionalMultipleOptionalUploadOperation.validateResult None [] let ``Should be able to execute a multiple optional upload asynchronously by sending no uploads``() : Task = task { - let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun() + let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(context) result |> OptionalMultipleOptionalUploadOperation.validateResult None } @@ -417,7 +418,7 @@ let ``Should be able to execute a multiple optional upload by sending some uploa None Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } None |] - OptionalMultipleOptionalUploadOperation.operation.Run(files |> Array.map (Option.map (fun f -> f.MakeUpload()))) + OptionalMultipleOptionalUploadOperation.operation.Run(context, files |> Array.map (Option.map (fun f -> f.MakeUpload()))) |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) [] @@ -427,7 +428,7 @@ let ``Should be able to execute a multiple optional upload asynchronously by sen None Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } None |] - let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(files |> Array.map (Option.map (fun f -> f.MakeUpload()))) + let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(context, files |> Array.map (Option.map (fun f -> f.MakeUpload()))) result |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) } @@ -484,7 +485,7 @@ let ``Should be able to upload files inside another input type``() : Task = task multiple = Array.map makeUpload request.Multiple, nullableMultiple = Array.map makeUpload request.NullableMultiple.Value, nullableMultipleNullable = Array.map (Option.map makeUpload) request.NullableMultipleNullable.Value) - let! result = UploadRequestOperation.operation.AsyncRun(input) + let! result = UploadRequestOperation.operation.AsyncRun(context, input) result |> UploadRequestOperation.validateResult request } @@ -506,7 +507,7 @@ module UploadComplexOperation = let ``Should be able to upload file using complex input object`` () = let file = { Name = "complex.txt"; ContentType = "text/plain"; Content = "Complex input object file content" } let input = UploadComplexOperation.InputFile(file = file.MakeUpload()) - UploadComplexOperation.operation.Run(input) + UploadComplexOperation.operation.Run(context, input) |> UploadComplexOperation.validateResult file [] @@ -520,7 +521,7 @@ let ``Should be able to upload file using complex input object with context`` () let ``Should be able to upload file using complex input object asynchronously`` () : Task = task { let file = { Name = "complex_async.txt"; ContentType = "text/plain"; Content = "Complex input object async file content" } let input = UploadComplexOperation.InputFile(file = file.MakeUpload()) - let! result = UploadComplexOperation.operation.AsyncRun(input) + let! result = UploadComplexOperation.operation.AsyncRun(context, input) result |> UploadComplexOperation.validateResult file } diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderWithOptionalParametersOnlyTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderWithOptionalParametersOnlyTests.fs index 74cc97a48..5422c356a 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderWithOptionalParametersOnlyTests.fs +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/LocalProviderWithOptionalParametersOnlyTests.fs @@ -5,12 +5,13 @@ open System.Threading.Tasks open FSharp.Data.GraphQL open Helpers -let [] ServerUrl = "http://localhost:8085" +let [] IntrospectionPath = "integration-introspection.json" let [] EmptyGuidAsString = "00000000-0000-0000-0000-000000000000" -type Provider = GraphQLProvider +type Provider = GraphQLProvider -let context = Provider.GetContext(ServerUrl) +let connection = TestHosts.createIntegrationConnection () +let context = Provider.GetContext(serverUrl = TestHosts.integrationServerUrl, connectionFactory = fun () -> connection) type Input = Provider.Types.Input type InputField = Provider.Types.InputField @@ -58,7 +59,7 @@ module SimpleOperation = [] let ``Should be able to execute a query without sending input field``() = - SimpleOperation.operation.Run() + SimpleOperation.operation.Run(context) |> SimpleOperation.validateResult None [] @@ -68,7 +69,7 @@ let ``Should be able to execute a query using context, without sending input fie [] let ``Should be able to execute a query without sending input field asynchronously``() = - SimpleOperation.operation.AsyncRun() + SimpleOperation.operation.AsyncRun(context) |> Async.RunSynchronously |> SimpleOperation.validateResult None @@ -81,7 +82,7 @@ let ``Should be able to execute a query using context, without sending input fie [] let ``Should be able to execute a query sending an empty input field``() = let input = Input() - SimpleOperation.operation.Run(Some input) + SimpleOperation.operation.Run(context, Some input) |> SimpleOperation.validateResult (Some input) [] @@ -93,7 +94,7 @@ let ``Should be able to execute a query using context, sending an empty input fi [] let ``Should be able to execute a query without sending an empty input field asynchronously``() : Task = task { let input = Input() - let! result = SimpleOperation.operation.AsyncRun(Some input) + let! result = SimpleOperation.operation.AsyncRun(context, Some input) result |> SimpleOperation.validateResult (Some input) } @@ -108,7 +109,7 @@ let ``Should be able to execute a query using context, sending an empty input fi let ``Should be able to execute a query sending an input field with single field``() = let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let input = Input(Some single) - SimpleOperation.operation.Run(Some input) + SimpleOperation.operation.Run(context, Some input) |> SimpleOperation.validateResult (Some input) [] @@ -122,7 +123,7 @@ let ``Should be able to execute a query using context, sending an input field wi let ``Should be able to execute a query without sending an input field with single field asynchronously``() : Task = task { let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let input = Input(Some single) - let! result = SimpleOperation.operation.AsyncRun(Some input) + let! result = SimpleOperation.operation.AsyncRun(context, Some input) result |> SimpleOperation.validateResult (Some input) } @@ -138,7 +139,7 @@ let ``Should be able to execute a query using context, sending an input field wi let ``Should be able to execute a query sending an input field with list field``() = let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(list = Some list) - SimpleOperation.operation.Run(Some input) + SimpleOperation.operation.Run(context, Some input) |> SimpleOperation.validateResult (Some input) [] @@ -152,7 +153,7 @@ let ``Should be able to execute a query using context, sending an input field wi let ``Should be able to execute a query without sending an input field with list field asynchronously``() : Task = task { let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(list = Some list) - let! result = SimpleOperation.operation.AsyncRun(Some input) + let! result = SimpleOperation.operation.AsyncRun(context, Some input) result |> SimpleOperation.validateResult (Some input) } @@ -169,7 +170,7 @@ let ``Should be able to execute a query sending an input field with single and l let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(Some single, Some list) - SimpleOperation.operation.Run(Some input) + SimpleOperation.operation.Run(context, Some input) |> SimpleOperation.validateResult (Some input) [] @@ -185,7 +186,7 @@ let ``Should be able to execute a query without sending an input field with sing let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString) let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|] let input = Input(Some single, Some list) - let! result = SimpleOperation.operation.AsyncRun(Some input) + let! result = SimpleOperation.operation.AsyncRun(context, Some input) result |> SimpleOperation.validateResult (Some input) } @@ -220,13 +221,13 @@ module SingleRequiredUploadOperation = [] let ``Should be able to execute a single required upload``() = let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - SingleRequiredUploadOperation.operation.Run(file.MakeUpload(file.Name)) + SingleRequiredUploadOperation.operation.Run(context, file.MakeUpload(file.Name)) |> SingleRequiredUploadOperation.validateResult file [] let ``Should be able to execute a single required upload asynchronously``() : Task = task { let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - let! result = SingleRequiredUploadOperation.operation.AsyncRun(file.MakeUpload()) + let! result = SingleRequiredUploadOperation.operation.AsyncRun(context, file.MakeUpload()) result |> SingleRequiredUploadOperation.validateResult file } @@ -254,24 +255,24 @@ module SingleOptionalUploadOperation = [] let ``Should be able to execute a single optional upload by passing a file``() = let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - SingleOptionalUploadOperation.operation.Run(file.MakeUpload() |> Some) + SingleOptionalUploadOperation.operation.Run(context, file.MakeUpload() |> Some) |> SingleOptionalUploadOperation.validateResult (Some file) [] let ``Should be able to execute a single optional upload by passing a file, asynchronously``() : Task = task { let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" } - let! result = SingleOptionalUploadOperation.operation.AsyncRun(file.MakeUpload("test") |> Some) + let! result = SingleOptionalUploadOperation.operation.AsyncRun(context, file.MakeUpload("test") |> Some) result |> SingleOptionalUploadOperation.validateResult (Some file) } [] let ``Should be able to execute a single optional upload by not passing a file``() = - SingleOptionalUploadOperation.operation.Run() + SingleOptionalUploadOperation.operation.Run(context) |> SingleOptionalUploadOperation.validateResult None [] let ``Should be able to execute a single optional upload by not passing a file asynchronously``() : Task = task { - let! result = SingleOptionalUploadOperation.operation.AsyncRun() + let! result = SingleOptionalUploadOperation.operation.AsyncRun(context) result |> SingleOptionalUploadOperation.validateResult None } @@ -300,7 +301,7 @@ let ``Should be able to execute a multiple required upload``() = let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - RequiredMultipleUploadOperation.operation.Run(files |> Array.map (fun f -> f.MakeUpload())) + RequiredMultipleUploadOperation.operation.Run(context, files |> Array.map (fun f -> f.MakeUpload())) |> RequiredMultipleUploadOperation.validateResult files [] @@ -308,7 +309,7 @@ let ``Should be able to execute a multiple required upload asynchronously``() : let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - let! result = RequiredMultipleUploadOperation.operation.AsyncRun(files |> Array.map (fun f -> f.MakeUpload())) + let! result = RequiredMultipleUploadOperation.operation.AsyncRun(context, files |> Array.map (fun f -> f.MakeUpload())) result |> RequiredMultipleUploadOperation.validateResult files } @@ -337,7 +338,7 @@ let ``Should be able to execute a multiple upload``() = let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - OptionalMultipleUploadOperation.operation.Run(files |> Array.map (fun f -> f.MakeUpload()) |> Some) + OptionalMultipleUploadOperation.operation.Run(context, files |> Array.map (fun f -> f.MakeUpload()) |> Some) |> OptionalMultipleUploadOperation.validateResult (Some files) [] @@ -345,18 +346,18 @@ let ``Should be able to execute a multiple upload asynchronously``() : Task = ta let files = [| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - let! result = OptionalMultipleUploadOperation.operation.AsyncRun((files |> Array.map _.MakeUpload()) |> Some) + let! result = OptionalMultipleUploadOperation.operation.AsyncRun(context, (files |> Array.map _.MakeUpload()) |> Some) result |> OptionalMultipleUploadOperation.validateResult (Some files) } [] let ``Should be able to execute a multiple upload by sending no uploads``() = - OptionalMultipleUploadOperation.operation.Run() + OptionalMultipleUploadOperation.operation.Run(context) |> OptionalMultipleUploadOperation.validateResult None [] let ``Should be able to execute a multiple upload asynchronously by sending no uploads``() : Task = task { - let! result = OptionalMultipleUploadOperation.operation.AsyncRun() + let! result = OptionalMultipleUploadOperation.operation.AsyncRun(context) result |> OptionalMultipleUploadOperation.validateResult None } @@ -385,7 +386,7 @@ let ``Should be able to execute a multiple optional upload``() = let files = [| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - OptionalMultipleOptionalUploadOperation.operation.Run((files |> Array.map (Option.map _.MakeUpload())) |> Some) + OptionalMultipleOptionalUploadOperation.operation.Run(context, (files |> Array.map (Option.map _.MakeUpload())) |> Some) |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) [] @@ -393,18 +394,18 @@ let ``Should be able to execute a multiple optional upload asynchronously``() : let files = [| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" } Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |] - let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun((files |> Array.map (Option.map _.MakeUpload())) |> Some) + let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(context, (files |> Array.map (Option.map _.MakeUpload())) |> Some) result |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) } [] let ``Should be able to execute a multiple optional upload by sending no uploads``() = - OptionalMultipleOptionalUploadOperation.operation.Run() + OptionalMultipleOptionalUploadOperation.operation.Run(context) |> OptionalMultipleOptionalUploadOperation.validateResult None [] let ``Should be able to execute a multiple optional upload asynchronously by sending no uploads``() : Task = task { - let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun() + let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(context) result |> OptionalMultipleOptionalUploadOperation.validateResult None } @@ -415,7 +416,7 @@ let ``Should be able to execute a multiple optional upload by sending some uploa None Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } None |] - OptionalMultipleOptionalUploadOperation.operation.Run(files |> Array.map (Option.map _.MakeUpload()) |> Some) + OptionalMultipleOptionalUploadOperation.operation.Run(context, files |> Array.map (Option.map _.MakeUpload()) |> Some) |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) [] @@ -425,7 +426,7 @@ let ``Should be able to execute a multiple optional upload asynchronously by sen None Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } None |] - let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(files |> Array.map (Option.map _.MakeUpload()) |> Some) + let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(context, files |> Array.map (Option.map _.MakeUpload()) |> Some) result |> OptionalMultipleOptionalUploadOperation.validateResult (Some files) } @@ -482,7 +483,7 @@ let ``Should be able to upload files inside another input type``() = multiple = Array.map makeUpload request.Multiple, nullableMultiple = Some (Array.map makeUpload request.NullableMultiple.Value), nullableMultipleNullable = Some (Array.map (Option.map makeUpload) request.NullableMultipleNullable.Value)) - UploadRequestOperation.operation.Run(input) + UploadRequestOperation.operation.Run(context, input) |> UploadRequestOperation.validateResult request module UploadComplexOperation = @@ -503,7 +504,7 @@ module UploadComplexOperation = let ``Should be able to upload file using complex input object`` () = let file = { Name = "complex.txt"; ContentType = "text/plain"; Content = "Complex input object file content" } let input = UploadComplexOperation.InputFile(file = file.MakeUpload()) - UploadComplexOperation.operation.Run(input) + UploadComplexOperation.operation.Run(context, input) |> UploadComplexOperation.validateResult file [] @@ -517,7 +518,7 @@ let ``Should be able to upload file using complex input object with context`` () let ``Should be able to upload file using complex input object asynchronously`` () : Task = task { let file = { Name = "complex_async.txt"; ContentType = "text/plain"; Content = "Complex input object async file content" } let input = UploadComplexOperation.InputFile(file = file.MakeUpload()) - let! result = UploadComplexOperation.operation.AsyncRun(input) + let! result = UploadComplexOperation.operation.AsyncRun(context, input) result |> UploadComplexOperation.validateResult file } diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/OperationErrorTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/OperationErrorTests.fs index f95b44df0..7dfa7b0f0 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/OperationErrorTests.fs +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/OperationErrorTests.fs @@ -7,9 +7,12 @@ open FSharp.Data.GraphQL open FSharp.Data.GraphQL.Client [] -let ServerUrl = "http://localhost:8085" +let IntrospectionPath = "integration-introspection.json" -type Provider = GraphQLProvider +type Provider = GraphQLProvider + +let connection = TestHosts.createIntegrationConnection () +let context = Provider.GetContext(serverUrl = TestHosts.integrationServerUrl, connectionFactory = fun () -> connection) module ErrorOperation = let operation = @@ -106,7 +109,7 @@ let ``Should parse all combinations of optional operation error fields`` () = [] let ``Should map server error extensions and locations into operation result`` () = - let result = ErrorOperation.operation.Run () + let result = ErrorOperation.operation.Run(context) result.Errors.Length |> equals 1 diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiLocalProviderTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiLocalProviderTests.fs index e673cba63..7d9ab8331 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiLocalProviderTests.fs +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiLocalProviderTests.fs @@ -3,17 +3,16 @@ module FSharp.Data.GraphQL.IntegrationTests.SwapiLocalProviderTests open Xunit open Helpers open FSharp.Data.GraphQL -open System.Net.Http open System.Threading.Tasks // Local provider should be able to be created from local introspection json file. type Provider = GraphQLProvider<"introspection.json"> // We are going to re-use the same HttpClient through all requests. -let connection = new GraphQLClientConnection(new HttpClient()) +let connection = TestHosts.createStarWarsConnection () // As we are not using a connection to a server to get the introspection, we need a runtime context. -let getContext() = Provider.GetContext(serverUrl = "http://localhost:8086", connectionFactory = fun () -> connection) +let getContext() = Provider.GetContext(serverUrl = TestHosts.starWarsServerUrl, connectionFactory = fun () -> connection) type Episode = Provider.Types.Episode diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiRemoteProviderTests.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiRemoteProviderTests.fs index dc73b38db..07a8c7ed0 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiRemoteProviderTests.fs +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/SwapiRemoteProviderTests.fs @@ -5,7 +5,10 @@ open Helpers open FSharp.Data.GraphQL open System.Threading.Tasks -type Provider = GraphQLProvider<"http://localhost:8086"> +type Provider = GraphQLProvider<"introspection.json"> + +let connection = TestHosts.createStarWarsConnection () +let context = Provider.GetContext(serverUrl = TestHosts.starWarsServerUrl, connectionFactory = fun () -> connection) type Episode = Provider.Types.Episode @@ -47,13 +50,27 @@ hero (id: "1000") { result.Data.IsSome |> equals true result.Data.Value.Hero.IsSome |> equals true result.Data.Value.Hero.Value.AppearsIn |> equals [| Episode.NewHope; Episode.Empire; Episode.Jedi |] - let expectedFriends : Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Character array = - [| Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Human(name = "Han Solo") - Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Human(name = "Leia Organa", homePlanet = "Alderaan") - Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Droid(name = "C-3PO", primaryFunction = "Protocol") - Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Droid(name = "R2-D2", primaryFunction = "Astromech") |] let friends = result.Data.Value.Hero.Value.Friends.Edges |> Array.map (fun e -> e.Node) - friends |> equals expectedFriends + friends.Length |> equals 4 + do + let friend0 = friends[0] + friend0.IsHuman() |> equals true + friend0.AsHuman().Name |> equals (Some "Han Solo") + do + let friend1 = friends[1] + friend1.IsHuman() |> equals true + friend1.AsHuman().Name |> equals (Some "Leia Organa") + friend1.AsHuman().HomePlanet |> equals (Some "Alderaan") + do + let friend2 = friends[2] + friend2.IsDroid() |> equals true + friend2.AsDroid().Name |> equals (Some "C-3PO") + friend2.AsDroid().PrimaryFunction |> equals (Some "Protocol") + do + let friend3 = friends[3] + friend3.IsDroid() |> equals true + friend3.AsDroid().Name |> equals (Some "R2-D2") + friend3.AsDroid().PrimaryFunction |> equals (Some "Astromech") result.Data.Value.Hero.Value.HomePlanet |> equals (Some "Tatooine") let actual = normalize <| sprintf "%A" result.Data let expected = normalize <| """Some @@ -80,18 +97,18 @@ hero (id: "1000") { [] let ``Should be able to start a simple query operation synchronously`` () = - SimpleOperation.operation.Run() + SimpleOperation.operation.Run(context) |> SimpleOperation.validateResult [] let ``Should be able to start a simple query operation asynchronously`` () : Task = task { - let! result = SimpleOperation.operation.AsyncRun() + let! result = SimpleOperation.operation.AsyncRun(context) result |> SimpleOperation.validateResult } [] let ``Should be able to use pattern matching methods on an union type`` () = - let result = SimpleOperation.operation.Run() + let result = SimpleOperation.operation.Run(context) result.Data.IsSome |> equals true result.Data.Value.Hero.IsSome |> equals true let friends = result.Data.Value.Hero.Value.Friends.Edges |> Array.map (fun e -> e.Node) @@ -149,12 +166,12 @@ module MutationOperation = [] let ``Should be able to run a mutation synchronously`` () = - MutationOperation.operation.Run() + MutationOperation.operation.Run(context) |> MutationOperation.validateResult [] let ``Should be able to run a mutation asynchronously`` () : Task = task { - let! result = MutationOperation.operation.AsyncRun() + let! result = MutationOperation.operation.AsyncRun(context) result |> MutationOperation.validateResult } @@ -169,13 +186,27 @@ module FileOperation = result.Data.IsSome |> equals true result.Data.Value.Hero.IsSome |> equals true result.Data.Value.Hero.Value.AppearsIn |> equals [| Episode.NewHope; Episode.Empire; Episode.Jedi |] - let expectedFriends : Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Character array = - [| Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Human(name = "Han Solo") - Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Human(name = "Leia Organa", homePlanet = "Alderaan") - Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Droid(name = "C-3PO", primaryFunction = "Protocol") - Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Droid(name = "R2-D2", primaryFunction = "Astromech") |] let friends = result.Data.Value.Hero.Value.Friends.Edges |> Array.map _.Node - friends |> equals expectedFriends + friends.Length |> equals 4 + do + let friend0 = friends[0] + friend0.IsHuman() |> equals true + friend0.AsHuman().Name |> equals (Some "Han Solo") + do + let friend1 = friends[1] + friend1.IsHuman() |> equals true + friend1.AsHuman().Name |> equals (Some "Leia Organa") + friend1.AsHuman().HomePlanet |> equals (Some "Alderaan") + do + let friend2 = friends[2] + friend2.IsDroid() |> equals true + friend2.AsDroid().Name |> equals (Some "C-3PO") + friend2.AsDroid().PrimaryFunction |> equals (Some "Protocol") + do + let friend3 = friends[3] + friend3.IsDroid() |> equals true + friend3.AsDroid().Name |> equals (Some "R2-D2") + friend3.AsDroid().PrimaryFunction |> equals (Some "Astromech") result.Data.Value.Hero.Value.HomePlanet |> equals (Some "Tatooine") let actual = normalize <| sprintf "%A" result.Data let expected = normalize <| """Some @@ -202,5 +233,5 @@ module FileOperation = [] let ``Should be able to run a query from a query file`` () = - FileOperation.fileOp.Run() + FileOperation.fileOp.Run(context) |> FileOperation.validateResult diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/TestHosts.fs b/tests/FSharp.Data.GraphQL.IntegrationTests/TestHosts.fs new file mode 100644 index 000000000..31478a08c --- /dev/null +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/TestHosts.fs @@ -0,0 +1,43 @@ +module FSharp.Data.GraphQL.IntegrationTests.TestHosts + +open FSharp.Data.GraphQL +open Microsoft.AspNetCore.Mvc.Testing +open System.Net.Http +open System + +type IntegrationServerApplicationFactory () = + inherit WebApplicationFactory () + +type StarWarsApplicationFactory () = + inherit WebApplicationFactory () + +let private integrationFactory = lazy (new IntegrationServerApplicationFactory ()) +let private starWarsFactory = lazy (new StarWarsApplicationFactory ()) + +let createIntegrationHttpClient () : HttpClient = + integrationFactory.Value.CreateClient () + +let createStarWarsHttpClient () : HttpClient = + starWarsFactory.Value.CreateClient () + +let private getIntegrationServerUrl () = + use client = createIntegrationHttpClient () + client.BaseAddress.ToString().TrimEnd '/' + +let private getStarWarsServerUrl () = + use client = createStarWarsHttpClient () + client.BaseAddress.ToString().TrimEnd '/' + +do + AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> + if integrationFactory.IsValueCreated then + integrationFactory.Value.Dispose () + + if starWarsFactory.IsValueCreated then + starWarsFactory.Value.Dispose ()) + +let integrationServerUrl = getIntegrationServerUrl () +let starWarsServerUrl = getStarWarsServerUrl () + +let createIntegrationConnection () = new GraphQLClientConnection (createIntegrationHttpClient ()) +let createStarWarsConnection () = new GraphQLClientConnection (createStarWarsHttpClient ()) diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/integration-introspection.json b/tests/FSharp.Data.GraphQL.IntegrationTests/integration-introspection.json new file mode 100644 index 000000000..ad448c42f --- /dev/null +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/integration-introspection.json @@ -0,0 +1,1929 @@ +{ + "documentId": 986164407, + "data": { + "__schema": { + "queryType": { + "name": "Query" + }, + "mutationType": { + "name": "Mutation" + }, + "subscriptionType": null, + "types": [ + { + "kind": "SCALAR", + "name": "Int", + "description": "The \u0060Int\u0060 scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "String", + "description": "The \u0060String\u0060 scalar type represents textual data, represented as UTF-8 character sequences. The \u0060String\u0060 type is most often used by GraphQL to represent free-form human-readable text.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "Boolean", + "description": "The \u0060Boolean\u0060 scalar type represents \u0060true\u0060 or \u0060false\u0060.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "Float", + "description": "The \u0060Float\u0060 scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "ID", + "description": "The \u0060ID\u0060 scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The \u0060ID\u0060 type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as \u0060\u00224\u0022\u0060) or integer (such as \u00604\u0060) input value will be accepted as an ID.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "DateTimeOffset", + "description": "The \u0060DateTimeOffset\u0060 scalar type represents a Date value with Time component. The \u0060DateTimeOffset\u0060 type appears in a JSON response as a String representation compatible with ISO-8601 format.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "DateOnly", + "description": "The \u0060DateOnly\u0060 scalar type represents a Date value without Time component. The \u0060DateOnly\u0060 type appears in a JSON response as a \u0060String\u0060 representation of full-date value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt).", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "TimeOnly", + "description": "The \u0060TimeOnly\u0060 scalar type represents a Time value without Date component. The \u0060TimeOnly\u0060 type appears in a JSON response as a \u0060String\u0060 representation of full-time value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt).", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "URI", + "description": "The \u0060URI\u0060 scalar type represents a string resource identifier compatible with URI standard. The \u0060URI\u0060 type appears in a JSON response as a String.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "__Schema", + "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", + "fields": [ + { + "name": "directives", + "description": "A list of all directives supported by this server.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Directive", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "mutationType", + "description": "If this server supports mutation, the type that mutation operations will be rooted at.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "queryType", + "description": "The type that query operations will be rooted at.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "subscriptionType", + "description": "If this server support subscription, the type that subscription operations will be rooted at.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "types", + "description": "A list of all types supported by this server.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "__Directive", + "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document. In some cases, you need to provide options to alter GraphQL\u2019s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + "fields": [ + { + "name": "args", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__InputValue", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "description", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "locations", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "__DirectiveLocation", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "name", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "onField", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "onFragment", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "onOperation", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "__InputValue", + "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", + "fields": [ + { + "name": "defaultValue", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "description", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "name", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "type", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "__Type", + "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \u0060__TypeKind\u0060 enum. Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", + "fields": [ + { + "name": "description", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "enumValues", + "description": null, + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false" + } + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__EnumValue", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "fields", + "description": null, + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false" + } + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Field", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "inputFields", + "description": null, + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__InputValue", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "interfaces", + "description": null, + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "kind", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "__TypeKind", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "name", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ofType", + "description": null, + "args": [], + "type": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "possibleTypes", + "description": null, + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "__EnumValue", + "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", + "fields": [ + { + "name": "deprecationReason", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "description", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "isDeprecated", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "name", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "__Field", + "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", + "fields": [ + { + "name": "args", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__InputValue", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deprecationReason", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "description", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "isDeprecated", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "name", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "type", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "__Type", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "ENUM", + "name": "__TypeKind", + "description": "An enum describing what kind of type a given __Type is.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "SCALAR", + "description": "Indicates this type is a scalar.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "OBJECT", + "description": "Indicates this type is an object. \u0060fields\u0060 and \u0060interfaces\u0060 are valid fields.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "INTERFACE", + "description": "Indicates this type is an interface. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "UNION", + "description": "Indicates this type is a union. \u0060possibleTypes\u0060 is a valid field.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ENUM", + "description": "Indicates this type is an enum. \u0060enumValues\u0060 is a valid field.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "INPUT_OBJECT", + "description": "Indicates this type is an input object. \u0060inputFields\u0060 is a valid field.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "LIST", + "description": "Indicates this type is a list. \u0060ofType\u0060 is a valid field.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "NON_NULL", + "description": "Indicates this type is a non-null. \u0060ofType\u0060 is a valid field.", + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, + { + "kind": "ENUM", + "name": "__DirectiveLocation", + "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "QUERY", + "description": "Location adjacent to a query operation.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "MUTATION", + "description": "Location adjacent to a mutation operation.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SUBSCRIPTION", + "description": "Location adjacent to a subscription operation.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "FIELD", + "description": "Location adjacent to a field.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "FRAGMENT_DEFINITION", + "description": "Location adjacent to a fragment definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "FRAGMENT_SPREAD", + "description": "Location adjacent to a fragment spread.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "INLINE_FRAGMENT", + "description": "Location adjacent to an inline fragment.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SCHEMA", + "description": "Location adjacent to a schema IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SCALAR", + "description": "Location adjacent to a scalar IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "OBJECT", + "description": "Location adjacent to an object IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "FIELD_DEFINITION", + "description": "Location adjacent to a field IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ARGUMENT_DEFINITION", + "description": "Location adjacent to a field argument IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "INTERFACE", + "description": "Location adjacent to an interface IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "UNION", + "description": "Location adjacent to an union IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ENUM", + "description": "Location adjacent to an enum IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ENUM_VALUE", + "description": "Location adjacent to an enum value definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "INPUT_OBJECT", + "description": "Location adjacent to an input object IDL definition.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "INPUT_FIELD_DEFINITION", + "description": "Location adjacent to an input object field IDL definition.", + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "Query", + "description": "The query type.", + "fields": [ + { + "name": "alwaysError", + "description": "Always produces an execution error for integration tests.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "echo", + "description": "Enters an input type and get it back.", + "args": [ + { + "name": "input", + "description": "The input to be echoed as an output.", + "type": { + "kind": "INPUT_OBJECT", + "name": "Input", + "ofType": null + }, + "defaultValue": null + } + ], + "type": { + "kind": "OBJECT", + "name": "Output", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "Output", + "description": "The output for an input.", + "fields": [ + { + "name": "list", + "description": "A list of output fields.", + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "OutputField", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "single", + "description": "A single output field.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "OutputField", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "OutputField", + "description": "The output for a field input.", + "fields": [ + { + "name": "deprecated", + "description": "A string value through a deprecated field.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": true, + "deprecationReason": "This field is deprecated." + }, + { + "name": "guid", + "description": "A Guid value.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Guid", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "guidId", + "description": "A Guid Id value.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "guidIdOption", + "description": "A Guid Id value.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "int", + "description": "An integer value.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "intOption", + "description": "An integer option value.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "string", + "description": "A string value.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "stringId", + "description": "A String Id value.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "stringIdOption", + "description": "A String Id value.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "stringOption", + "description": "A string option value.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "uri", + "description": "An URI value.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "URI", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "Guid", + "description": "The \u0060Guid\u0060 scalar type represents a Globally Unique Identifier value. It\u0027s a 128-bit long byte key, that can be serialized to string.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "Input", + "description": "Input object type.", + "fields": null, + "inputFields": [ + { + "name": "single", + "description": "A single input field.", + "type": { + "kind": "INPUT_OBJECT", + "name": "InputField", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "list", + "description": "A list of input fields.", + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "InputField", + "ofType": null + } + } + }, + "defaultValue": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "InputField", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "string", + "description": "A string value.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "defaultValue": null + }, + { + "name": "int", + "description": "An integer value.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + } + }, + "defaultValue": null + }, + { + "name": "stringOption", + "description": "A string option value.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "intOption", + "description": "An integer option value.", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "defaultValue": null + }, + { + "name": "uri", + "description": "An URI value.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "URI", + "ofType": null + } + }, + "defaultValue": null + }, + { + "name": "guid", + "description": "A Guid value.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Guid", + "ofType": null + } + }, + "defaultValue": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "Mutation", + "description": null, + "fields": [ + { + "name": "multipleUpload", + "description": "Uploads a list of files to the server and get them back.", + "args": [ + { + "name": "files", + "description": "The files to upload.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + } + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "nullableMultipleNullableUpload", + "description": "Uploads (maybe) a list of files (maybe) to the server and get them back (maybe).", + "args": [ + { + "name": "files", + "description": "The files to upload.", + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "nullableMultipleUpload", + "description": "Uploads (maybe) a list of files to the server and get them back (maybe).", + "args": [ + { + "name": "files", + "description": "The files to upload.", + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "nullableSingleUpload", + "description": "Uploads (maybe) a single file to the server and get it back (maybe).", + "args": [ + { + "name": "file", + "description": "The file to be uploaded.", + "type": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + }, + "defaultValue": null + } + ], + "type": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "singleUpload", + "description": "Uploads a single file to the server and get it back.", + "args": [ + { + "name": "file", + "description": "The file to be uploaded.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "uploadComplex", + "description": "", + "args": [ + { + "name": "input", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "InputFile", + "ofType": null + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "uploadRequest", + "description": "Upload several files in different forms.", + "args": [ + { + "name": "request", + "description": "The request for uploading several files in different forms.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "UploadRequest", + "ofType": null + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadResponse", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "UploadedFile", + "description": "Contains data of an uploaded file.", + "fields": [ + { + "name": "contentAsText", + "description": "The content of the file as text.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "contentType", + "description": "The content type of the file.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "name", + "description": "The name of the file.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "File", + "description": "The \u0060File\u0060 type represents a file on one or more fields of an object in an object list. The filter is represented by a JSON object where the fields are the complemented by specific suffixes to represent a query.", + "fields": null, + "inputFields": [], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "InputFile", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "file", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + }, + "defaultValue": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "UploadResponse", + "description": "Contains uploaded files of an upload files request.", + "fields": [ + { + "name": "multiple", + "description": "Multiple file uploads.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "nullableMultiple", + "description": "Optional list of multiple file uploads.", + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "nullableMultipleNullable", + "description": "Optional list of multiple optional file uploads.", + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "single", + "description": "A single file upload.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "UploadedFile", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "UploadRequest", + "description": "Request for uploading files in several different forms.", + "fields": null, + "inputFields": [ + { + "name": "single", + "description": "A single file upload.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + }, + "defaultValue": null + }, + { + "name": "multiple", + "description": "Multiple file uploads.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + } + } + }, + "defaultValue": null + }, + { + "name": "nullableMultiple", + "description": "Optional list of multiple file uploads.", + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + } + }, + "defaultValue": null + }, + { + "name": "nullableMultipleNullable", + "description": "Optional list of multiple optional file uploads.", + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "File", + "ofType": null + } + }, + "defaultValue": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + } + ], + "directives": [ + { + "name": "include", + "description": "Directs the executor to include this field or fragment only when the \u0060if\u0060 argument is true.", + "locations": [ + "FIELD", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], + "args": [ + { + "name": "if", + "description": "Included when true.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "defaultValue": null + } + ] + }, + { + "name": "skip", + "description": "Directs the executor to skip this field or fragment when the \u0060if\u0060 argument is true.", + "locations": [ + "FIELD", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], + "args": [ + { + "name": "if", + "description": "Skipped when true.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "defaultValue": null + } + ] + }, + { + "name": "defer", + "description": "Defers the resolution of this field or fragment", + "locations": [ + "FIELD", + "FRAGMENT_DEFINITION", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], + "args": [] + }, + { + "name": "stream", + "description": "Streams the resolution of this field or fragment", + "locations": [ + "FIELD", + "FRAGMENT_DEFINITION", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], + "args": [] + }, + { + "name": "live", + "description": "Subscribes for live updates of this field or fragment", + "locations": [ + "FIELD", + "FRAGMENT_DEFINITION", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], + "args": [] + } + ] + } + } +} \ No newline at end of file diff --git a/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json b/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json index 7b3d9abcf..a961111fd 100644 --- a/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json +++ b/tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json @@ -1,5 +1,5 @@ { - "documentId": -128167532, + "documentId": 195530235, "data": { "__schema": { "queryType": {