mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 08:15:54 +08:00
15 lines
470 B
JavaScript
15 lines
470 B
JavaScript
import {print} from 'graphql-tag/printer';
|
|
|
|
// quick way to add the subscribe and unsubscribe functions to the network interface
|
|
const addGraphQLSubscriptions = (networkInterface, wsClient) => Object.assign(networkInterface, {
|
|
subscribe: (request, handler) => wsClient.subscribe({
|
|
query: print(request.query),
|
|
variables: request.variables,
|
|
}, handler),
|
|
unsubscribe: (id) => {
|
|
wsClient.unsubscribe(id);
|
|
},
|
|
});
|
|
|
|
export default addGraphQLSubscriptions;
|