Files
speckle-server/packages/frontend-2/codegen.ts
T
Kristaps Fabians Geikins 596ccf8ee3 feat(fe2): greatly improved DX for apollo cache modification (#2831)
* proof of concept - types work

* WIP

* wipp

* new modifyObjectFieldf

* updatePathIfExists

* wipp

* working?

* projects dashboard test

* more improvements

* more improvements

* fixx

* bugfix

* minor fixes and cleanup

* moar cleanup

* autoEvictFiltered
2024-09-03 10:59:16 +03: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: ['./tools/gqlCacheHelpersCodegenPlugin.js']
}
}
}
export default config