-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcodegen.ts
53 lines (49 loc) · 1.26 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
import { ContractsENV, SUBGRAPH_URLS } from '@fluencelabs/deal-ts-clients'
import type { CodegenConfig } from '@graphql-codegen/cli'
import * as dotenv from 'dotenv'
dotenv.config()
const pluginsConfig = {
/**
* Fail if there are unknown scalars (that are mapped to `any` type)
*/
strictScalars: true,
/**
* Import types with `import type { ... }`
*/
useTypeImports: true,
emitLegacyCommonJSImports: false,
enumsAsTypes: true,
/**
* The Graph custom scalars
*/
scalars: {
BigInt: 'string',
BigDecimal: 'string',
Bytes: 'string',
Int8: 'number',
Timestamp: 'number',
},
/**
* This makes import look like `import { gql } from "graphql-tag"`
* and not `import gql from "graphql-tag"`, fixing "This expression is not callable"
*/
gqlImport: 'graphql-tag#gql',
}
const FLUENCE_CLIENT_NETWORK = (process.env.VITE_FLUENCE_CLIENT_NETWORK ||
'local') as ContractsENV
const config: CodegenConfig = {
schema: SUBGRAPH_URLS[FLUENCE_CLIENT_NETWORK],
documents: 'src/**/*.graphql',
generates: {
'generated/graphql.ts': {
plugins: [
'typescript',
'typescript-operations',
'typescript-graphql-request',
],
config: pluginsConfig,
},
},
watch: false,
}
export default config