mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-13 15:46:22 +00:00
git-subtree-dir: packages/browseros-agent git-subtree-mainline:8f148d0918git-subtree-split:90bd4be300
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { existsSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { includeIgnoreFile } from '@eslint/compat'
|
|
import type { CodegenConfig } from '@graphql-codegen/cli'
|
|
|
|
// biome-ignore lint/style/noProcessEnv: env needed for codegen config
|
|
const env = process.env
|
|
|
|
const schemaPath =
|
|
env.GRAPHQL_SCHEMA_PATH ?? path.resolve(__dirname, 'schema/schema.graphql')
|
|
if (!existsSync(schemaPath)) {
|
|
throw new Error(
|
|
'No schema found. Either set GRAPHQL_SCHEMA_PATH in .env.development ' +
|
|
'or ensure schema/schema.graphql exists',
|
|
)
|
|
}
|
|
|
|
const gitignorePath = path.resolve(__dirname, '.gitignore')
|
|
|
|
const ignorePatterns = includeIgnoreFile(
|
|
gitignorePath,
|
|
'Imported .gitignore patterns',
|
|
)
|
|
|
|
const ignoresList = ignorePatterns.ignores?.map((each) => `!${each}`) ?? []
|
|
|
|
const config: CodegenConfig = {
|
|
schema: schemaPath,
|
|
documents: ['./**/*.tsx', './**/*.ts', ...ignoresList],
|
|
ignoreNoDocuments: true,
|
|
generates: {
|
|
'./generated/graphql/': {
|
|
preset: 'client',
|
|
config: {
|
|
documentMode: 'string',
|
|
},
|
|
},
|
|
'./generated/graphql/schema.graphql': {
|
|
plugins: ['schema-ast'],
|
|
config: {
|
|
includeDirectives: true,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
export default config
|