2022-11-19 08:09:52 +00:00
|
|
|
import { createClient } from '@urql/core'
|
|
|
|
import { isDev } from '../utils/config'
|
|
|
|
|
|
|
|
const localClient = (options) => {
|
|
|
|
console.info('[graphql] using local client')
|
2022-11-19 17:16:52 +00:00
|
|
|
options.url = 'http://localhost:8080'
|
|
|
|
return createClient(options)
|
2022-11-19 08:09:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const initClient = (options) => {
|
|
|
|
try {
|
|
|
|
if (isDev) {
|
|
|
|
console.info('[graphql] devmode detected')
|
|
|
|
return localClient(options)
|
|
|
|
} else return createClient(options)
|
2022-11-19 08:16:00 +00:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
2022-11-19 08:09:52 +00:00
|
|
|
return localClient(options)
|
|
|
|
}
|
|
|
|
}
|