25 lines
618 B
TypeScript
25 lines
618 B
TypeScript
import { ClientOptions, dedupExchange, fetchExchange, Exchange, createClient } from '@urql/core'
|
|
import { devtoolsExchange } from '@urql/devtools'
|
|
|
|
import { isDev, apiBaseUrl } from '../utils/config'
|
|
// import { cache } from './cache'
|
|
|
|
const exchanges: Exchange[] = [dedupExchange, fetchExchange] //, cache]
|
|
|
|
if (isDev) {
|
|
exchanges.unshift(devtoolsExchange)
|
|
}
|
|
|
|
const options: ClientOptions = {
|
|
url: apiBaseUrl,
|
|
maskTypename: true,
|
|
requestPolicy: 'cache-and-network',
|
|
exchanges,
|
|
}
|
|
|
|
export const getPublicClient = (name: string) =>
|
|
createClient({
|
|
...options,
|
|
url: `https://${name}.discours.io`,
|
|
})
|