forked from amplication/amplication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
37 lines (34 loc) · 1.01 KB
/
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
36
37
import { CodegenConfig } from "@graphql-codegen/cli";
import type { Types } from "@graphql-codegen/plugin-helpers";
import serverProject from "./packages/amplication-server/project.json";
const generates = serverProject.targets[
"graphql:models:generate"
].outputs.reduce(
(acc, curr) => {
curr = curr.replace("{workspaceRoot}/", "");
if (curr === "packages/amplication-client/src/models.ts") {
acc[curr] = {
documents: ["packages/amplication-client/src/**/*.query.ts"],
plugins: [
"typescript",
"typescript-operations",
"typescript-react-apollo",
],
config: { withHooks: true },
};
} else acc[curr] = { plugins: ["typescript"] };
return acc;
},
{} as {
[outputPath: string]: Types.ConfiguredOutput | Types.ConfiguredPlugin[];
}
);
const config: CodegenConfig = {
overwrite: true,
schema: "packages/amplication-server/src/schema.graphql",
config: {
skipTypename: true,
},
generates,
};
export default config;