-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsubgraph-config.js
44 lines (39 loc) · 1.27 KB
/
subgraph-config.js
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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { loadEnvConfig } = require('@next/env')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const devEndpoints = require('./src/subgraph/subgraph-endpoints-dev.json')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const endpoints = require('./src/subgraph/subgraph-endpoints.json')
if (Object.keys(endpoints).length) {
loadEnvConfig(process.cwd())
const codeGenOutDir = 'types/generated/subgraph.ts'
const schemas = Object.values(devEndpoints).reduce((acc, current) => {
return [...acc, ...Object.values(current)].filter((v) => !!v)
}, [])
module.exports = {
overwrite: true,
schema: schemas,
documents: 'src/subgraph/queries/**/*.ts',
generates: {
[codeGenOutDir]: {
plugins: [
'typescript',
'typescript-operations',
'typescript-graphql-request',
'plugin-typescript-swr',
{
// Workaround to handle the following error
// https://github.com/dotansimha/graphql-code-generator/issues/9046
add: {
content: '// @ts-nocheck',
},
},
],
},
},
config: {
rawRequest: false,
autogenSWRKey: true,
},
}
}