Skip to content

Commit 77a6d7e

Browse files
committed
test APQ with websocket transport
1 parent 97312ee commit 77a6d7e

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tests/GraphQL.Integration.Tests/APQ/APQViaHttpRequests.cs renamed to tests/GraphQL.Integration.Tests/APQ/AdvancedPersistentQueriesTest.cs

+29-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
namespace GraphQL.Integration.Tests.APQ;
1010

1111
[SuppressMessage("ReSharper", "UseConfigureAwaitFalse")]
12-
public class APQViaHttpRequests : IAsyncLifetime, IClassFixture<SystemTextJsonAutoNegotiateServerTestFixture>
12+
public class AdvancedPersistentQueriesTest : IAsyncLifetime, IClassFixture<SystemTextJsonAutoNegotiateServerTestFixture>
1313
{
1414
public SystemTextJsonAutoNegotiateServerTestFixture Fixture { get; }
1515
protected GraphQLHttpClient StarWarsClient;
16+
protected GraphQLHttpClient StarWarsWebsocketClient;
1617

17-
public APQViaHttpRequests(SystemTextJsonAutoNegotiateServerTestFixture fixture)
18+
public AdvancedPersistentQueriesTest(SystemTextJsonAutoNegotiateServerTestFixture fixture)
1819
{
1920
Fixture = fixture;
2021
}
@@ -23,6 +24,11 @@ public async Task InitializeAsync()
2324
{
2425
await Fixture.CreateServer();
2526
StarWarsClient = Fixture.GetStarWarsClient(options => options.EnableAutomaticPersistedQueries = _ => true);
27+
StarWarsWebsocketClient = Fixture.GetStarWarsClient(options =>
28+
{
29+
options.EnableAutomaticPersistedQueries = _ => true;
30+
options.UseWebSocketForQueriesAndMutations = true;
31+
});
2632
}
2733

2834
public Task DisposeAsync()
@@ -51,4 +57,25 @@ query Human($id: String!){
5157
Assert.Equal(name, response.Data.Human.Name);
5258
StarWarsClient.APQDisabledForSession.Should().BeFalse("if APQ has worked it won't get disabled");
5359
}
60+
61+
[Theory]
62+
[ClassData(typeof(StarWarsHumans))]
63+
public async void After_querying_all_starwars_humans_using_websocket_transport_the_APQDisabledForSession_is_still_false_Async(int id, string name)
64+
{
65+
var query = new GraphQLQuery("""
66+
query Human($id: String!){
67+
human(id: $id) {
68+
name
69+
}
70+
}
71+
""");
72+
73+
var graphQLRequest = new GraphQLRequest(query, new { id = id.ToString() });
74+
75+
var response = await StarWarsWebsocketClient.SendQueryAsync(graphQLRequest, () => new { Human = new { Name = string.Empty } });
76+
77+
Assert.Null(response.Errors);
78+
Assert.Equal(name, response.Data.Human.Name);
79+
StarWarsWebsocketClient.APQDisabledForSession.Should().BeFalse("if APQ has worked it won't get disabled");
80+
}
5481
}

0 commit comments

Comments
 (0)