-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodegen.ts
56 lines (52 loc) · 1.34 KB
/
codegen.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import type { CodegenConfig } from '@graphql-codegen/cli';
import { generate } from '@graphql-codegen/cli';
const GONDI_API = process.env.GONDI_API ?? 'https://api.gondi.xyz/lending/graphql';
console.log('Using schema', GONDI_API);
const config: CodegenConfig = {
generates: {
'src/generated/graphql/index.ts': {
schema: [GONDI_API],
documents: ['./src/api/graphql/**/*.gql'],
plugins: [
'typescript',
'typescript-operations',
'typescript-apollo-client-helpers',
'typescript-generic-sdk',
{
add: {
content: [
'/* eslint-disable */',
'//@ts-nocheck',
"import { Address, Hash, Hex } from 'viem'",
],
},
},
],
config: {
defaultBaseOptions: {
context: {
clientName: 'lending',
},
},
scalars: {
DateTime: 'Date',
Decimal: 'decimal',
BigInt: 'bigint',
Hash: 'Hash',
Address: 'Address',
Signature: 'Hex',
Hex: 'Hex',
JSON: 'object',
},
},
},
'src/generated/graphql/lending-schema.graphql': {
schema: [GONDI_API],
plugins: ['schema-ast'],
},
},
hooks: {
afterOneFileWrite: ['prettier --write'],
},
};
await generate(config);