CLI to generate types based on your Strapi API content types.
yarn add strapi-generate-types
or
npm install --save strapi-generate-types
In order to use this generator you must have installed the GraphQL plugin on your Strapi API.
yarn strapi install graphql
For more informations see the GraphQL plugin
yarn strapi-generate-types generate
OR
npx strapi-generate-types generate
The prompt will ask you 3 things:
http://localhost:1337
)../models/
).types.ts
)Enjoy 🎉
If you don't want to use the prompt everytime you run the generator, you can use the quickgen
:
yarn|npx strapi quickgen <url> [-p, --path <location>, default: "./models/"] [-n, --file-name <filename>, default: "types.ts"]