mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 23:10:43 +08:00
17 lines
500 B
JavaScript
17 lines
500 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) => {
|
|
return Object.assign(networkInterface, {
|
|
subscribe: (request, handler) => wsClient.subscribe({
|
|
query: print(request.query),
|
|
variables: request.variables,
|
|
}, handler),
|
|
unsubscribe: (id) => {
|
|
wsClient.unsubscribe(id);
|
|
},
|
|
});
|
|
};
|
|
|
|
export default addGraphQLSubscriptions;
|