1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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;
|