forked from smartcontractkit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
35 lines (30 loc) · 834 Bytes
/
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
import { CodegenConfig } from "@graphql-codegen/cli"
import dotenv from "dotenv"
dotenv.config()
const requiredEnvVars = ["GRAPHQL_SERVER_URL", "GRAPHQL_API_TOKEN"] as const
requiredEnvVars.forEach((envVar) => {
if (!process.env[envVar]) {
throw new Error(`Environment variable ${envVar} is not set. Please check your .env file.`)
}
})
const config: CodegenConfig = {
schema: [
{
[process.env.GRAPHQL_SERVER_URL as string]: {
headers: {
Authorization: `${process.env.GRAPHQL_API_TOKEN}`,
},
},
},
],
documents: "src/graphql/queries/**/*.gql",
generates: {
"src/graphql/generated.ts": {
plugins: ["typescript", "typescript-operations", "typescript-graphql-request"],
config: {
avoidOptionals: true,
},
},
},
}
export default config