-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
58 lines (52 loc) · 1.39 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
57
58
import type { CodegenConfig } from '@graphql-codegen/cli'
import { addTypenameSelectionDocumentTransform } from '@graphql-codegen/client-preset'
import dotenv from 'dotenv'
import path from 'path'
// .env 파일 로드
dotenv.config({ path: path.resolve(__dirname, '.env') })
const SUPABASE_ANON_KEY = process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY
const SUPABASE_URL = process.env.EXPO_PUBLIC_SUPABASE_URL
if (!SUPABASE_ANON_KEY) {
throw new Error('EXPO_PUBLIC_SUPABASE_ANON_KEY is not set in .env file')
}
if (!SUPABASE_URL) {
throw new Error('EXPO_PUBLIC_SUPABASE_URL is not set in .env file')
}
const config: CodegenConfig = {
schema: [
{
[`${SUPABASE_URL}/graphql/v1`]: {
headers: {
apiKey: SUPABASE_ANON_KEY,
'Content-Type': 'application/json'
}
}
}
],
documents: ['./src/**/*.tsx', './src/**/*.ts'],
overwrite: true,
ignoreNoDocuments: true,
generates: {
'./gql/': {
preset: 'client',
documentTransforms: [addTypenameSelectionDocumentTransform],
plugins: [],
config: {
scalars: {
UUID: 'string',
Date: 'string',
Time: 'string',
Datetime: 'string',
JSON: 'string',
BigInt: 'string',
BigFloat: 'string',
Opaque: 'any'
}
}
}
},
hooks: {
afterAllFileWrite: ['npm run prettier']
}
}
export default config