webapp/src/graphql/publicGraphQLClient.ts
2023-11-28 18:36:00 +03:00

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`,
})