9
9
namespace GraphQL . Integration . Tests . APQ ;
10
10
11
11
[ SuppressMessage ( "ReSharper" , "UseConfigureAwaitFalse" ) ]
12
- public class APQViaHttpRequests : IAsyncLifetime , IClassFixture < SystemTextJsonAutoNegotiateServerTestFixture >
12
+ public class AdvancedPersistentQueriesTest : IAsyncLifetime , IClassFixture < SystemTextJsonAutoNegotiateServerTestFixture >
13
13
{
14
14
public SystemTextJsonAutoNegotiateServerTestFixture Fixture { get ; }
15
15
protected GraphQLHttpClient StarWarsClient ;
16
+ protected GraphQLHttpClient StarWarsWebsocketClient ;
16
17
17
- public APQViaHttpRequests ( SystemTextJsonAutoNegotiateServerTestFixture fixture )
18
+ public AdvancedPersistentQueriesTest ( SystemTextJsonAutoNegotiateServerTestFixture fixture )
18
19
{
19
20
Fixture = fixture ;
20
21
}
@@ -23,6 +24,11 @@ public async Task InitializeAsync()
23
24
{
24
25
await Fixture . CreateServer ( ) ;
25
26
StarWarsClient = Fixture . GetStarWarsClient ( options => options . EnableAutomaticPersistedQueries = _ => true ) ;
27
+ StarWarsWebsocketClient = Fixture . GetStarWarsClient ( options =>
28
+ {
29
+ options . EnableAutomaticPersistedQueries = _ => true ;
30
+ options . UseWebSocketForQueriesAndMutations = true ;
31
+ } ) ;
26
32
}
27
33
28
34
public Task DisposeAsync ( )
@@ -51,4 +57,25 @@ query Human($id: String!){
51
57
Assert . Equal ( name , response . Data . Human . Name ) ;
52
58
StarWarsClient . APQDisabledForSession . Should ( ) . BeFalse ( "if APQ has worked it won't get disabled" ) ;
53
59
}
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
+ }
54
81
}
0 commit comments