@@ -142,21 +142,36 @@ class SocketClientConfig {
142142}
143143
144144/// All the protocol supported by the library
145- @Deprecated ("`SocketSubProtocol`is deprecated and will be removed in the version 5.2.0, consider to use `GraphQLProtocol`" )
145+ @Deprecated (
146+ "`SocketSubProtocol`is deprecated and will be removed in the version 5.2.0, consider to use `GraphQLProtocol`" )
146147class SocketSubProtocol {
147148 SocketSubProtocol ._();
149+
148150 /// graphql-ws: The new (not to be confused with the graphql-ws library).
149151 /// NB. This protocol is it no longer maintained, please consider
150152 /// to use `SocketSubProtocol.graphqlTransportWs` .
151153 static const String graphqlWs = GraphQLProtocol .graphqlWs;
152- /// graphql-transport-ws: New ws protocol used by most Apollo Server instances
154+
155+ /// graphql-transport-ws: New ws protocol used by most Apollo Server instances
153156 /// with subscriptions enabled use this library.
154- /// N.B: not to be confused with the graphql-ws library that implement the
157+ /// N.B: not to be confused with the graphql-ws library that implement the
155158 /// old ws protocol.
156159 static const String graphqlTransportWs = GraphQLProtocol .graphqlWs;
157160}
158161
162+ /// ALL protocol supported by the library
163+ class GraphQLProtocol {
164+ GraphQLProtocol ._();
165+
166+ /// graphql-ws: The new (not to be confused with the graphql-ws library).
167+ /// NB. This protocol is it no longer maintained, please consider
168+ /// to use `SocketSubProtocol.graphqlTransportWs` .
159169 static const String graphqlWs = "graphql-ws" ;
170+
171+ /// graphql-transport-ws: New ws protocol used by most Apollo Server instances
172+ /// with subscriptions enabled use this library.
173+ /// N.B: not to be confused with the graphql-ws library that implement the
174+ /// old ws protocol.
160175 static const String graphqlTransportWs = "graphql-transport-ws" ;
161176}
162177
@@ -171,7 +186,7 @@ class SocketSubProtocol {
171186class SocketClient {
172187 SocketClient (
173188 this .url, {
174- this .protocol = SocketSubProtocol .graphqlWs,
189+ this .protocol = GraphQLProtocol .graphqlWs,
175190 this .config = const SocketClientConfig (),
176191 @visibleForTesting this .randomBytesForUuid,
177192 @visibleForTesting this .onMessage,
@@ -259,14 +274,14 @@ class SocketClient {
259274 await config.connect (uri: Uri .parse (url), protocols: [protocol]);
260275 socketChannel = connection.forGraphQL ();
261276
262- if (protocol == SocketSubProtocol .graphqlTransportWs) {
277+ if (protocol == GraphQLProtocol .graphqlTransportWs) {
263278 _connectionStateController.add (SocketConnectionState .handshake);
264279 } else {
265280 _connectionStateController.add (SocketConnectionState .connected);
266281 }
267282 print ('Initialising connection' );
268283 _write (initOperation);
269- if (protocol == SocketSubProtocol .graphqlTransportWs) {
284+ if (protocol == GraphQLProtocol .graphqlTransportWs) {
270285 // wait for ack
271286 // this blocks to prevent ping from being called before ack is recieved
272287 await _messages.firstWhere (
@@ -275,10 +290,10 @@ class SocketClient {
275290 }
276291
277292 if (config.inactivityTimeout != null ) {
278- if (protocol == SocketSubProtocol .graphqlWs) {
293+ if (protocol == GraphQLProtocol .graphqlWs) {
279294 _disconnectOnKeepAliveTimeout (_messages);
280295 }
281- if (protocol == SocketSubProtocol .graphqlTransportWs) {
296+ if (protocol == GraphQLProtocol .graphqlTransportWs) {
282297 _enqueuePing ();
283298 }
284299 }
@@ -289,7 +304,7 @@ class SocketClient {
289304 onMessage !(message);
290305 }
291306
292- if (protocol == SocketSubProtocol .graphqlTransportWs) {
307+ if (protocol == GraphQLProtocol .graphqlTransportWs) {
293308 if (message.type == 'ping' ) {
294309 _write (PongMessage ());
295310 } else if (message.type == 'pong' ) {
@@ -506,7 +521,7 @@ class SocketClient {
506521 id,
507522 serialize (payload),
508523 );
509- if (protocol == SocketSubProtocol .graphqlTransportWs) {
524+ if (protocol == GraphQLProtocol .graphqlTransportWs) {
510525 operation = SubscribeOperation (
511526 id,
512527 serialize (payload),
@@ -524,7 +539,7 @@ class SocketClient {
524539 _subscriptionInitializers.remove (id);
525540
526541 sub? .cancel ();
527- if (protocol == SocketSubProtocol .graphqlWs &&
542+ if (protocol == GraphQLProtocol .graphqlWs &&
528543 _connectionStateController.value == SocketConnectionState .connected &&
529544 socketChannel != null ) {
530545 _write (StopOperation (id));
0 commit comments