2022-11-19 08:09:52 +00:00
|
|
|
import { ClientOptions, dedupExchange, fetchExchange, Exchange } 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-19 08:09:52 +00:00
|
|
|
import { initClient } from './client'
|
2022-11-19 08:53:27 +00:00
|
|
|
import { cache } from './cache'
|
2022-09-09 11:53:35 +00:00
|
|
|
|
2022-11-19 08:53:27 +00:00
|
|
|
const exchanges: Exchange[] = [dedupExchange, fetchExchange, cache]
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
|
|
if (isDev) {
|
|
|
|
exchanges.unshift(devtoolsExchange)
|
|
|
|
}
|
|
|
|
|
|
|
|
const options: ClientOptions = {
|
2022-10-25 16:25:42 +00:00
|
|
|
url: apiBaseUrl,
|
2022-09-09 11:53:35 +00:00
|
|
|
maskTypename: true,
|
|
|
|
requestPolicy: 'cache-and-network',
|
|
|
|
exchanges
|
|
|
|
}
|
|
|
|
|
2022-11-19 08:09:52 +00:00
|
|
|
export const publicGraphQLClient = initClient(options)
|