-
Notifications
You must be signed in to change notification settings - Fork 602
/
.graphqlrc.ts
56 lines (50 loc) · 1.25 KB
/
.graphqlrc.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
import { loadEnvConfig } from "@next/env";
import type { CodegenConfig } from "@graphql-codegen/cli";
loadEnvConfig(process.cwd());
let schemaUrl = process.env.NEXT_PUBLIC_SALEOR_API_URL;
if (process.env.GITHUB_ACTION === "generate-schema-from-file") {
schemaUrl = "schema.graphql";
}
if (!schemaUrl) {
console.error(
"Before GraphQL types can be generated, you need to set NEXT_PUBLIC_SALEOR_API_URL environment variable.",
);
console.error("Follow development instructions in the README.md file.");
process.exit(1);
}
const config: CodegenConfig = {
overwrite: true,
schema: schemaUrl,
documents: "src/graphql/**/*.graphql",
generates: {
"src/gql/": {
preset: "client",
plugins: [],
config: {
documentMode: "string",
useTypeImports: true,
strictScalars: true,
scalars: {
Date: "string",
DateTime: "string",
Day: "number",
Decimal: "number",
GenericScalar: "unknown",
JSON: "unknown",
JSONString: "string",
Metadata: "Record<string, string>",
Minute: "number",
PositiveDecimal: "number",
UUID: "string",
Upload: "unknown",
WeightScalar: "unknown",
_Any: "unknown",
},
},
presetConfig: {
fragmentMasking: false,
},
},
},
};
export default config;