webapp/src/graphql/publicGraphQLClient.ts

25 lines
618 B
TypeScript
Raw Normal View History

2022-11-20 18:49:44 +00:00
import { ClientOptions, dedupExchange, fetchExchange, Exchange, createClient } from '@urql/core'
2022-09-09 11:53:35 +00:00
import { devtoolsExchange } from '@urql/devtools'
2022-10-25 16:25:42 +00:00
import { isDev, apiBaseUrl } from '../utils/config'
2022-11-21 00:26:20 +00:00
// import { cache } from './cache'
2022-09-09 11:53:35 +00:00
2022-11-19 13:43:25 +00:00
const exchanges: Exchange[] = [dedupExchange, fetchExchange] //, cache]
2022-09-09 11:53:35 +00:00
if (isDev) {
exchanges.unshift(devtoolsExchange)
}
const options: ClientOptions = {
2023-02-17 09:21:02 +00:00
url: apiBaseUrl,
2022-09-09 11:53:35 +00:00
maskTypename: true,
requestPolicy: 'cache-and-network',
exchanges,
2022-09-09 11:53:35 +00:00
}
2023-11-28 13:18:25 +00:00
export const getPublicClient = (name: string) =>
createClient({
...options,
2023-11-28 15:36:00 +00:00
url: `https://${name}.discours.io`,
2023-11-28 13:18:25 +00:00
})