Files
speckle-server/packages/frontend-2/codegen.ts
T
Kristaps Fabians Geikins f80a7189a0 chore(fe2): upgrade to nuxt 3.8.2 (#1887)
* chore(fe2): upgrade to nuxt 3.8.2

* fix tailwind-theme build

* readme update

* removing storybook from fe2 :(

* fix(fe2): codegen schema url resolution
2023-11-29 10:22:17 +02:00

44 lines
1.1 KiB
TypeScript

import type { CodegenConfig } from '@graphql-codegen/cli'
import dotenv from 'dotenv'
import { trimEnd } from 'lodash'
// make nuxt env vars available here
dotenv.config()
const getApiOrigin = () => {
const backendApiOrigin = process.env.NUXT_PUBLIC_BACKEND_API_ORIGIN
if (backendApiOrigin?.length) return backendApiOrigin
const apiOrigin = process.env.NUXT_PUBLIC_API_ORIGIN
if (apiOrigin?.length) return apiOrigin
return 'http://127.0.0.1:3000'
}
const config: CodegenConfig = {
schema: `${trimEnd(getApiOrigin(), '/')}/graphql`,
documents: ['{lib,components,layouts,pages,middleware}/**/*.{vue,js,ts}'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
'./lib/common/generated/gql/': {
preset: 'client',
config: {
useTypeImports: true,
fragmentMasking: false,
dedupeFragments: true,
scalars: {
JSONObject: '{}',
DateTime: 'string'
}
},
presetConfig: {
fragmentMasking: false,
dedupeFragments: true
},
plugins: []
}
}
}
export default config