-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
32 lines (28 loc) · 803 Bytes
/
codegen.ts
File metadata and controls
32 lines (28 loc) · 803 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
27
28
29
30
31
32
import 'dotenv/config';
import type { CodegenConfig } from '@graphql-codegen/cli';
const endpoint = process.env.OXID_GRAPHQL_URL;
if (!endpoint) throw new Error('Missing OXID_GRAPHQL_ENDPOINT in .env');
const config: CodegenConfig = {
schema: [
{
[endpoint]: {},
},
],
// IMPORTANT: read gql tags from TS files
documents: ['src/**/*.{ts,tsx}'],
generates: {
'src/generated/types.ts': {
plugins: ['typescript', 'typescript-operations'],
config: {
useTypeImports: true,
/**
* We keep documents in TS (via gql tag),
* only generate types (no DocumentNodes re-emitted).
*/
documentMode: 'graphQLTag',
gqlTagName: 'gql', // the tag we’ll use in our TS ops
},
},
},
};
export default config;