-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TestServer support for GraphQLHttpClient
- Loading branch information
1 parent
fe110b6
commit 73060d6
Showing
18 changed files
with
360 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/GraphQL.Client.TestHost/GraphQL.Client.TestHost.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net461;netstandard2.1</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\GraphQL.Client\GraphQL.Client.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using GraphQL.Client.Abstractions.Websocket; | ||
using GraphQL.Client.Http; | ||
using Microsoft.AspNetCore.TestHost; | ||
|
||
namespace GraphQL.Client.TestHost | ||
{ | ||
public static class TestServerExtensions | ||
{ | ||
public static GraphQLHttpClient CreateGraphQLHttpClient(this TestServer server, GraphQLHttpClientOptions options, IGraphQLWebsocketJsonSerializer serializer) | ||
{ | ||
var testWebSocketClient = server.CreateWebSocketClient(); | ||
testWebSocketClient.ConfigureRequest = r => | ||
{ | ||
r.Headers["Sec-WebSocket-Protocol"] = "graphql-ws"; | ||
}; | ||
|
||
return new GraphQLHttpClient(options, serializer, server.CreateClient(), (uri, token) => testWebSocketClient.ConnectAsync(uri, token)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/GraphQL.Integration.Tests/Helpers/NewtonsoftIntegrationServerTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using GraphQL.Client.Abstractions.Websocket; | ||
using GraphQL.Client.Serializer.Newtonsoft; | ||
|
||
namespace GraphQL.Integration.Tests.Helpers | ||
{ | ||
public class NewtonsoftIntegrationServerTestFixture : IntegrationServerTestFixture | ||
{ | ||
public override IGraphQLWebsocketJsonSerializer Serializer { get; } = new NewtonsoftJsonSerializer(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/GraphQL.Integration.Tests/Helpers/SystemTextJsonIntegrationServerTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using GraphQL.Client.Abstractions.Websocket; | ||
using GraphQL.Client.Serializer.SystemTextJson; | ||
|
||
namespace GraphQL.Integration.Tests.Helpers | ||
{ | ||
public class SystemTextJsonIntegrationServerTestFixture : IntegrationServerTestFixture | ||
{ | ||
public override IGraphQLWebsocketJsonSerializer Serializer { get; } = new SystemTextJsonSerializer(); | ||
} | ||
} |
Oops, something went wrong.