forked from amplication/amplication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
36 lines (33 loc) · 981 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
36
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) => {
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;