Skip to content

Commit 038e39a

Browse files
committed
[codegen ci] add fallback subgraph codegen check
1 parent b9b44ba commit 038e39a

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

codegen.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,28 @@ import { Network } from './src/utils/enums'
44
import configs from './src/utils/configs'
55

66

7-
// For every network we have same gql shema, so we can use just Mainnet here
8-
const urls = configs[Network.Holesky].api
7+
let network: Network = Network.Holesky
8+
9+
if (process.env.NETWORK === 'mainnet') {
10+
network = Network.Mainnet
11+
}
12+
if (process.env.NETWORK === 'gnosis') {
13+
network = Network.Gnosis
14+
}
15+
16+
const config = configs[network]
17+
const subgraphIndex = Number(process.env.SUBGRAPH_INDEX || 0)
18+
19+
const subgraphUrl = Array.isArray(config.api.subgraph)
20+
? config.api.subgraph[subgraphIndex]
21+
: config.api.subgraph
22+
23+
const urls: Record<string, string> = {
24+
backend: config.api.backend,
25+
subgraph: subgraphUrl,
26+
}
27+
28+
console.log(`Generating types for network: ${config.network.id}`, urls)
929

1030
// https://the-guild.dev/graphql/codegen/plugins/typescript/typescript
1131
const typesConfig = {

0 commit comments

Comments
 (0)