-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
26 lines (22 loc) · 834 Bytes
/
codegen.ts
File metadata and controls
26 lines (22 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { CodegenConfig } from '@graphql-codegen/cli';
// Prefer environment variable, fall back to SvelteKit env if available, finally fallback to local schema file
let schema: string | undefined = process.env.PLEXAMS_SERVER;
try {
// Try to load SvelteKit env when running inside svelte environment
// eslint-disable-next-line @typescript-eslint/no-var-requires
const svelteEnv = require('$env/dynamic/private');
if (!schema && svelteEnv?.env?.PLEXAMS_SERVER) schema = svelteEnv.env.PLEXAMS_SERVER;
} catch (e) {
// ignore - require will fail outside sveltekit
}
if (!schema) schema = './schema.graphql';
const config: CodegenConfig = {
schema,
// documents: ['src/**/*.graphql'],
generates: {
'./src/lib/__generated__/graphql.ts': {
plugins: ['typescript', 'typescript-operations']
}
}
};
export default config;