.graphqlrc.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { loadEnvConfig } from "@next/env";
  2. import type { CodegenConfig } from "@graphql-codegen/cli";
  3. loadEnvConfig(process.cwd());
  4. let schemaUrl = process.env.NEXT_PUBLIC_SALEOR_API_URL;
  5. if (process.env.GITHUB_ACTION === "generate-schema-from-file") {
  6. schemaUrl = "schema.graphql";
  7. }
  8. if (!schemaUrl) {
  9. console.error(
  10. "Before GraphQL types can be generated, you need to set NEXT_PUBLIC_SALEOR_API_URL environment variable.",
  11. );
  12. console.error("Follow development instructions in the README.md file.");
  13. process.exit(1);
  14. }
  15. const config: CodegenConfig = {
  16. overwrite: true,
  17. schema: schemaUrl,
  18. documents: "src/graphql/**/*.graphql",
  19. generates: {
  20. "src/gql/": {
  21. preset: "client",
  22. plugins: [],
  23. config: {
  24. documentMode: "string",
  25. useTypeImports: true,
  26. strictScalars: true,
  27. scalars: {
  28. Date: "string",
  29. DateTime: "string",
  30. Day: "number",
  31. Decimal: "number",
  32. GenericScalar: "unknown",
  33. JSON: "unknown",
  34. JSONString: "string",
  35. Metadata: "Record<string, string>",
  36. Minute: "number",
  37. PositiveDecimal: "number",
  38. UUID: "string",
  39. Upload: "unknown",
  40. WeightScalar: "unknown",
  41. _Any: "unknown",
  42. },
  43. },
  44. presetConfig: {
  45. fragmentMasking: false,
  46. },
  47. },
  48. },
  49. };
  50. export default config;