Skip to content

Commit 8e20828

Browse files
committed
Rename ApolloSubscriptionServer class
Change class name to just "SubscriptionServer"
1 parent 13af026 commit 8e20828

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ $ pip install graphql-subscriptions
4848

4949
#### Methods
5050
- `publish(trigger_name, payload)`: Trigger name is the subscription or pubsub channel; payload is the mutation object or message that will end up being passed to the subscription root_value; method called inside of mutation resolve function
51-
- `subscribe(query, operation_name, callback, variables, context, format_error, format_response)`: Called by ApolloSubscriptionServer upon receiving a new subscription from a websocket. Arguments are parsed by ApolloSubscriptionServer from the graphql subscription query
52-
- `unsubscribe(sub_id)`: Sub_id is the subscription ID that is being tracked by the subscription manager instance -- returned from the `subscribe()` method and called by the ApolloSubscriptionServer
51+
- `subscribe(query, operation_name, callback, variables, context, format_error, format_response)`: Called by SubscriptionServer upon receiving a new subscription from a websocket. Arguments are parsed by SubscriptionServer from the graphql subscription query
52+
- `unsubscribe(sub_id)`: Sub_id is the subscription ID that is being tracked by the subscription manager instance -- returned from the `subscribe()` method and called by the SubscriptionServer
5353

54-
### ApolloSubscriptionServer(subscription_manager, websocket, keep_alive=None, on_subscribe=None, on_unsubscribe=None, on_connect=None, on_disconnect=None)
54+
### SubscriptionServer(subscription_manager, websocket, keep_alive=None, on_subscribe=None, on_unsubscribe=None, on_connect=None, on_disconnect=None)
5555
#### Arguments
5656
- `subscription_manager`: A subscripton manager instance (required).
5757
- `websocket`: The websocket object passed in from your route handler (required).
@@ -78,7 +78,7 @@ from flask_sockets import Sockets
7878
from graphql_subscriptions import (
7979
SubscriptionManager,
8080
RedisPubsub,
81-
ApolloSubscriptionServer
81+
SubscriptionServer
8282
)
8383

8484
app = Flask(__name__)
@@ -106,7 +106,7 @@ subscription_mgr = SubscriptionManager(schema, pubsub)
106106
# subscription app / server -- passing in subscription manager and websocket
107107
@sockets.route('/socket')
108108
def socket_channel(websocket):
109-
subscription_server = ApolloSubscriptionServer(subscription_mgr, websocket)
109+
subscription_server = SubscriptionServer(subscription_mgr, websocket)
110110
subscription_server.handle()
111111
return []
112112

graphql_subscriptions/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from subscription_manager import RedisPubsub, SubscriptionManager
2-
from subscription_transport_ws import ApolloSubscriptionServer
2+
from subscription_transport_ws import SubscriptionServer
3+
4+
__all__ = ['RedisPubsub', 'SubscriptionManager', 'SubscriptionServer']
35

4-
__all__ = ['RedisPubsub', 'SubscriptionManager', 'ApolloSubscriptionServer']

graphql_subscriptions/subscription_transport_ws.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
GRAPHQL_SUBSCRIPTIONS = 'graphql-subscriptions'
1616

1717

18-
class ApolloSubscriptionServer(WebSocketApplication):
18+
class SubscriptionServer(WebSocketApplication):
1919
def __init__(self,
2020
subscription_manager,
2121
websocket,
@@ -37,7 +37,7 @@ def __init__(self,
3737
self.connection_subscriptions = {}
3838
self.connection_context = {}
3939

40-
super(ApolloSubscriptionServer, self).__init__(websocket)
40+
super(SubscriptionServer, self).__init__(websocket)
4141

4242
def timer(self, callback, period):
4343
while True:

tests/test_subscription_transport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import requests
2626

2727
from graphql_subscriptions import (RedisPubsub, SubscriptionManager,
28-
ApolloSubscriptionServer)
28+
SubscriptionServer)
2929

3030
from graphql_subscriptions.subscription_transport_ws import (
3131
SUBSCRIPTION_FAIL, SUBSCRIPTION_DATA, KEEPALIVE)
@@ -264,7 +264,7 @@ def sub_mgr_publish():
264264

265265
@sockets.route('/socket')
266266
def socket_channel(websocket):
267-
subscription_server = ApolloSubscriptionServer(sub_mgr, websocket,
267+
subscription_server = SubscriptionServer(sub_mgr, websocket,
268268
**options)
269269
subscription_server.handle()
270270
return []
@@ -323,7 +323,7 @@ def server_with_events(sub_mgr, schema, events_options):
323323

324324
def test_raise_exception_when_create_server_and_no_sub_mgr():
325325
with pytest.raises(AssertionError):
326-
ApolloSubscriptionServer(None, None)
326+
SubscriptionServer(None, None)
327327

328328

329329
def test_should_trigger_on_connect_if_client_connect_valid(server_with_events):

0 commit comments

Comments
 (0)