Note: This is not an officially supported solution. It's something that could work but may require some additional tweaks to be 100% usable.
To learn how to customize GraphQL Code Generator, see their documentation.
-
Install packages
npm i -D @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations node-fetch@cjs @prismicio/client@beta ts-node
-
Add a file named
scripts/gen.ts
. See the gist for file contents. Update it for your project (repository name, access token, source files, generated file name, etc.). -
Add a script to
package.json
{ "scripts": { "gen": "ts-node-script --skip-project scripts/gen.ts" } }
When you need types to be generated, run the following command.
npm run gen