This commit is contained in:
tonyrewin 2022-12-12 10:41:49 +03:00
parent 072213fcc0
commit a2f24fbe55

View File

@ -6,8 +6,8 @@ import {
subscriptionExchange, subscriptionExchange,
createClient createClient
} from '@urql/core' } from '@urql/core'
// import { createClient as createSSEClient } from 'graphql-sse' import { createClient as createSubClient } from 'graphql-sse'
import { createClient as createWSClient } from 'graphql-ws' // import { createClient as createSubClient } from 'graphql-ws'
import { devtoolsExchange } from '@urql/devtools' import { devtoolsExchange } from '@urql/devtools'
import { isDev, apiBaseUrl } from '../utils/config' import { isDev, apiBaseUrl } from '../utils/config'
// import { cache } from './cache' // import { cache } from './cache'
@ -56,15 +56,15 @@ const options: ClientOptions = {
export const privateGraphQLClient = createClient(options) export const privateGraphQLClient = createClient(options)
export const createChatClient = () => { export const createChatClient = () => {
const sseClient = createWSClient({ const subClient = createSubClient({
url: apiBaseUrl.replace('http', 'ws') url: apiBaseUrl + '/messages' // .replace('http', 'ws')
}) })
const subExchange = subscriptionExchange({ const subExchange = subscriptionExchange({
forwardSubscription(operation) { forwardSubscription(operation) {
return { return {
subscribe: (sink) => { subscribe: (sink) => {
const dispose = sseClient.subscribe(operation, sink) const dispose = subClient.subscribe(operation, sink)
return { return {
unsubscribe: dispose unsubscribe: dispose
} }