Files
Dani Akash 290ee91a8b Add 'packages/browseros-agent/' from commit '90bd4be3008285bf3825aad3702aff98f872671a'
git-subtree-dir: packages/browseros-agent
git-subtree-mainline: 8f148d0918
git-subtree-split: 90bd4be300
2026-03-13 21:22:09 +05:30

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