From 041f327f87e4cca4ba49f6c37d0a7bfa303ca2de Mon Sep 17 00:00:00 2001 From: Alexander Rose Date: Tue, 20 Nov 2018 22:12:48 +0100 Subject: [PATCH 01/49] Observable Subscriptions (#80) * create observable subscription * create integration test server and test project * fix debug output * create basic unit test for subscription * make unit test politically correct * make sure all ClientWebSockets are disposed on disposing the GraphQlHttpClient * fix comment * Modified GraphQL.Client.csproj --- GraphQL.Client.sln | 16 +- src/GraphQL.Client/GraphQL.Client.csproj | 5 +- src/GraphQL.Client/Http/GraphQLHttpClient.cs | 37 ++- .../Http/GraphQLHttpObservableSubscription.cs | 268 ++++++++++++++++++ .../Http/GraphQLHttpSubscriptionResult.cs | 8 +- .../Http/HttpClientExtensions.cs | 10 + src/GraphQL.Client/IGraphQLClient.cs | 2 + .../Response/GraphQLSubscriptionResponse.cs | 2 +- .../GraphQL.Client.Tests.csproj | 4 +- .../GraphQL.Integration.Tests.csproj | 28 ++ .../GraphQLClientExtensions.cs | 34 +++ .../ObservableTester.cs | 151 ++++++++++ .../Properties/launchSettings.json | 27 ++ .../SubscriptionsTest.cs | 114 ++++++++ .../WebApplicationFactoryExtensions.cs | 19 ++ .../ChatSchema/ChatMutation.cs | 31 ++ .../ChatSchema/ChatQuery.cs | 13 + .../ChatSchema/ChatSchema.cs | 14 + .../ChatSchema/ChatSubscriptions.cs | 74 +++++ .../IntegrationTestServer/ChatSchema/IChat.cs | 79 ++++++ .../ChatSchema/Message.cs | 15 + .../ChatSchema/MessageFrom.cs | 9 + .../ChatSchema/MessageFromType.cs | 13 + .../ChatSchema/MessageType.cs | 21 ++ .../ChatSchema/ReceivedMessage.cs | 13 + .../IntegrationTestServer.csproj | 22 ++ tests/IntegrationTestServer/Program.cs | 17 ++ .../Properties/launchSettings.json | 28 ++ tests/IntegrationTestServer/Startup.cs | 69 +++++ 29 files changed, 1127 insertions(+), 16 deletions(-) create mode 100644 src/GraphQL.Client/Http/GraphQLHttpObservableSubscription.cs create mode 100644 tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj create mode 100644 tests/GraphQL.Integration.Tests/GraphQLClientExtensions.cs create mode 100644 tests/GraphQL.Integration.Tests/ObservableTester.cs create mode 100644 tests/GraphQL.Integration.Tests/Properties/launchSettings.json create mode 100644 tests/GraphQL.Integration.Tests/SubscriptionsTest.cs create mode 100644 tests/GraphQL.Integration.Tests/WebApplicationFactoryExtensions.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/ChatMutation.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/ChatQuery.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/ChatSchema.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/ChatSubscriptions.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/IChat.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/Message.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/MessageFrom.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/MessageFromType.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/MessageType.cs create mode 100644 tests/IntegrationTestServer/ChatSchema/ReceivedMessage.cs create mode 100644 tests/IntegrationTestServer/IntegrationTestServer.csproj create mode 100644 tests/IntegrationTestServer/Program.cs create mode 100644 tests/IntegrationTestServer/Properties/launchSettings.json create mode 100644 tests/IntegrationTestServer/Startup.cs diff --git a/GraphQL.Client.sln b/GraphQL.Client.sln index 45a422a5..722a7d85 100644 --- a/GraphQL.Client.sln +++ b/GraphQL.Client.sln @@ -43,7 +43,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".circleci", ".circleci", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9413EC62-CDDE-4E77-9784-E1136EA5D1EE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL.Client.Sample", "samples\GraphQL.Client.Sample\GraphQL.Client.Sample.csproj", "{B21E97C3-F328-473F-A054-A4BF272B63F0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Sample", "samples\GraphQL.Client.Sample\GraphQL.Client.Sample.csproj", "{B21E97C3-F328-473F-A054-A4BF272B63F0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Integration.Tests", "tests\GraphQL.Integration.Tests\GraphQL.Integration.Tests.csproj", "{86BC3878-6549-4EF1-9672-B7C15A3FDF46}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTestServer", "tests\IntegrationTestServer\IntegrationTestServer.csproj", "{618653E5-41C2-4F17-BE4F-F904267500D4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -71,6 +75,14 @@ Global {B21E97C3-F328-473F-A054-A4BF272B63F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {B21E97C3-F328-473F-A054-A4BF272B63F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {B21E97C3-F328-473F-A054-A4BF272B63F0}.Release|Any CPU.Build.0 = Release|Any CPU + {86BC3878-6549-4EF1-9672-B7C15A3FDF46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86BC3878-6549-4EF1-9672-B7C15A3FDF46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86BC3878-6549-4EF1-9672-B7C15A3FDF46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86BC3878-6549-4EF1-9672-B7C15A3FDF46}.Release|Any CPU.Build.0 = Release|Any CPU + {618653E5-41C2-4F17-BE4F-F904267500D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {618653E5-41C2-4F17-BE4F-F904267500D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {618653E5-41C2-4F17-BE4F-F904267500D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {618653E5-41C2-4F17-BE4F-F904267500D4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -83,6 +95,8 @@ Global {6326E0E2-3F48-4BAF-80D3-47AED5EB647C} = {63F75859-4698-4EDE-8B70-4ACBB8BC425A} {C1406F03-650F-4633-887D-312943251919} = {63F75859-4698-4EDE-8B70-4ACBB8BC425A} {B21E97C3-F328-473F-A054-A4BF272B63F0} = {9413EC62-CDDE-4E77-9784-E1136EA5D1EE} + {86BC3878-6549-4EF1-9672-B7C15A3FDF46} = {0B0EDB0F-FF67-4B78-A8DB-B5C23E1FEE8C} + {618653E5-41C2-4F17-BE4F-F904267500D4} = {0B0EDB0F-FF67-4B78-A8DB-B5C23E1FEE8C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {387AC1AC-F90C-4EF8-955A-04D495C75AF4} diff --git a/src/GraphQL.Client/GraphQL.Client.csproj b/src/GraphQL.Client/GraphQL.Client.csproj index 99a24460..200758df 100644 --- a/src/GraphQL.Client/GraphQL.Client.csproj +++ b/src/GraphQL.Client/GraphQL.Client.csproj @@ -1,11 +1,11 @@ - + A GraphQL Client - netstandard1.3;netstandard2.0 + netstandard2.0 @@ -14,6 +14,7 @@ +