Skip to content

Commit d8dc43e

Browse files
committed
chore: generate graphql typegen files on build
1 parent 708b6ed commit d8dc43e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gatsby-node.ts

+18
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import type { GatsbyNode } from "gatsby";
2+
import {
3+
writeGraphQLConfig,
4+
writeGraphQLFragments,
5+
writeGraphQLSchema,
6+
} from "gatsby/dist/utils/graphql-typegen/file-writes";
27
import path from "path";
38
import slugify from "slugify";
49

510
import { SearchItem } from "./src/types/catalog";
611

12+
export const onPostBuild: GatsbyNode["onPostBuild"] = async ({ store }) => {
13+
const { program, config, schema, definitions } = store.getState();
14+
15+
if (
16+
process.env.gatsby_executing_command === `build` &&
17+
config.graphqlTypegen
18+
) {
19+
await writeGraphQLConfig(program);
20+
await writeGraphQLSchema(program.directory, schema);
21+
await writeGraphQLFragments(program.directory, definitions);
22+
}
23+
};
24+
725
export const createPages: GatsbyNode["createPages"] = async ({
826
graphql,
927
actions,

0 commit comments

Comments
 (0)