This commit is contained in:
Igor Lobanov 2022-11-20 19:49:44 +01:00
parent 417e3a7bdf
commit 36a4443ed2
6 changed files with 34 additions and 30 deletions

View File

@ -25,6 +25,7 @@
"preview": "astro preview", "preview": "astro preview",
"server": "node server/server.mjs", "server": "node server/server.mjs",
"start": "astro dev", "start": "astro dev",
"start:local": "cross-env PUBLIC_API_URL=http://localhost:8080 astro dev",
"typecheck": "astro check && tsc --noEmit", "typecheck": "astro check && tsc --noEmit",
"typecheck:watch": "tsc --noEmit --watch", "typecheck:watch": "tsc --noEmit --watch",
"vercel-build": "astro build" "vercel-build": "astro build"
@ -46,7 +47,7 @@
"@nanostores/router": "^0.7.0", "@nanostores/router": "^0.7.0",
"@nanostores/solid": "^0.3.0", "@nanostores/solid": "^0.3.0",
"@popperjs/core": "^2.11.6", "@popperjs/core": "^2.11.6",
"@solid-devtools/debugger": "^0.15.0", "@solid-devtools/debugger": "^0.15.1",
"@solid-devtools/logger": "^0.5.0", "@solid-devtools/logger": "^0.5.0",
"@solid-primitives/memo": "^1.1.2", "@solid-primitives/memo": "^1.1.2",
"@solid-primitives/storage": "^1.3.3", "@solid-primitives/storage": "^1.3.3",
@ -65,6 +66,7 @@
"clsx": "^1.2.1", "clsx": "^1.2.1",
"cookie": "^0.5.0", "cookie": "^0.5.0",
"cookie-signature": "^1.2.0", "cookie-signature": "^1.2.0",
"cross-env": "^7.0.3",
"eslint": "^8.27.0", "eslint": "^8.27.0",
"eslint-config-stylelint": "^17.0.0", "eslint-config-stylelint": "^17.0.0",
"eslint-import-resolver-typescript": "^3.5.2", "eslint-import-resolver-typescript": "^3.5.2",

View File

@ -1,20 +0,0 @@
import { createClient } from '@urql/core'
import { isDev } from '../utils/config'
const localClient = (options) => {
console.info('[graphql] using local client')
const url = 'http://localhost:8080'
return createClient({ ...options, url })
}
export const initClient = (options) => {
try {
if (isDev) {
console.info('[graphql] devmode detected')
return localClient(options)
} else return createClient(options)
} catch (error) {
console.error(error)
return localClient(options)
}
}

View File

@ -1,7 +1,6 @@
import { ClientOptions, dedupExchange, fetchExchange, Exchange } from '@urql/core' import { ClientOptions, dedupExchange, fetchExchange, Exchange, createClient } from '@urql/core'
import { devtoolsExchange } from '@urql/devtools' import { devtoolsExchange } from '@urql/devtools'
import { isDev, apiBaseUrl } from '../utils/config' import { isDev, apiBaseUrl } from '../utils/config'
import { initClient } from './client'
// import { cache } from './cache' // import { cache } from './cache'
const TOKEN_LOCAL_STORAGE_KEY = 'token' const TOKEN_LOCAL_STORAGE_KEY = 'token'
@ -39,4 +38,4 @@ const options: ClientOptions = {
exchanges exchanges
} }
export const privateGraphQLClient = initClient(options) export const privateGraphQLClient = createClient(options)

View File

@ -1,7 +1,6 @@
import { ClientOptions, dedupExchange, fetchExchange, Exchange } from '@urql/core' import { ClientOptions, dedupExchange, fetchExchange, Exchange, createClient } from '@urql/core'
import { devtoolsExchange } from '@urql/devtools' import { devtoolsExchange } from '@urql/devtools'
import { isDev, apiBaseUrl } from '../utils/config' import { isDev, apiBaseUrl } from '../utils/config'
import { initClient } from './client'
import { cache } from './cache' import { cache } from './cache'
const exchanges: Exchange[] = [dedupExchange, fetchExchange] //, cache] const exchanges: Exchange[] = [dedupExchange, fetchExchange] //, cache]
@ -17,4 +16,4 @@ const options: ClientOptions = {
exchanges exchanges
} }
export const publicGraphQLClient = initClient(options) export const publicGraphQLClient = createClient(options)

View File

@ -1,4 +1,4 @@
export const isDev = import.meta.env.MODE === 'development' export const isDev = import.meta.env.MODE === 'development'
// export const apiBaseUrl = 'https://v2.discours.io' const defaultApiUrl = 'https://testapi.discours.io'
export const apiBaseUrl = 'https://testapi.discours.io' export const apiBaseUrl = import.meta.env.PUBLIC_API_URL || defaultApiUrl

View File

@ -1655,6 +1655,23 @@
"@solid-primitives/utils" "^4.0.0" "@solid-primitives/utils" "^4.0.0"
type-fest "^3.2.0" type-fest "^3.2.0"
"@solid-devtools/debugger@^0.15.1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@solid-devtools/debugger/-/debugger-0.15.1.tgz#c98ccf401be9efb2965809de27525e6175ea6d6c"
integrity sha512-E5vXsdemei9T/k/0X0GyZFvKpHiz73am3o8PmWV6vYhipvwVgPRnBvvHI85IjmtqBKK8gqHVtqu2D2qNu0rN2w==
dependencies:
"@solid-devtools/shared" "^0.10.1"
"@solid-devtools/transform" "^0.9.0"
"@solid-primitives/bounds" "^0.0.105"
"@solid-primitives/cursor" "^0.0.103"
"@solid-primitives/event-bus" "^0.1.3"
"@solid-primitives/event-listener" "^2.2.3"
"@solid-primitives/keyboard" "^1.0.3"
"@solid-primitives/platform" "^0.0.102"
"@solid-primitives/scheduled" "^1.2.0"
"@solid-primitives/utils" "^4.0.0"
type-fest "^3.2.0"
"@solid-devtools/logger@^0.5.0": "@solid-devtools/logger@^0.5.0":
version "0.5.1" version "0.5.1"
resolved "https://registry.yarnpkg.com/@solid-devtools/logger/-/logger-0.5.1.tgz#7481f05246a558b680e2fbbaeafd8dc60b9ff949" resolved "https://registry.yarnpkg.com/@solid-devtools/logger/-/logger-0.5.1.tgz#7481f05246a558b680e2fbbaeafd8dc60b9ff949"
@ -3401,6 +3418,13 @@ crelt@^1.0.0:
resolved "https://registry.yarnpkg.com/crelt/-/crelt-1.0.5.tgz#57c0d52af8c859e354bace1883eb2e1eb182bb94" resolved "https://registry.yarnpkg.com/crelt/-/crelt-1.0.5.tgz#57c0d52af8c859e354bace1883eb2e1eb182bb94"
integrity sha512-+BO9wPPi+DWTDcNYhr/W90myha8ptzftZT+LwcmUbbok0rcP/fequmFYCw8NMoH7pkAZQzU78b3kYrlua5a9eA== integrity sha512-+BO9wPPi+DWTDcNYhr/W90myha8ptzftZT+LwcmUbbok0rcP/fequmFYCw8NMoH7pkAZQzU78b3kYrlua5a9eA==
cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
dependencies:
cross-spawn "^7.0.1"
cross-fetch@^3.1.5: cross-fetch@^3.1.5:
version "3.1.5" version "3.1.5"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
@ -3408,7 +3432,7 @@ cross-fetch@^3.1.5:
dependencies: dependencies:
node-fetch "2.6.7" node-fetch "2.6.7"
cross-spawn@^7.0.2, cross-spawn@^7.0.3: cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3" version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==