Command Line Interface (CLI)
Generate Typescript's Types based on your Strapi content types. 💡
Features
Generate Typescript's types based on your content types
Usage of GraphQL Code Generator to generate types
Ease-of-use thanks a beautiful prompt
Getting started
⏳ Installation
You can easily install this CLI thanks your favorite package manager:
yarn add strapi-generate-types
npm install --save strapi-generate-types
🖐 Requirements
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
🕹 Usage
The usage depend on which package manager you're using:
yarn strapi-generate-types generate
npx strapi-generate-types generate
The prompt will ask you 3 things:
- First, the host of your Strapi API with which you want to generate your types (default:
http://localhost:1337
). - Then, where you want to generate it (default:
./models/
). - Finally, the name of the file which will be generated (default:
types.ts
)
Enjoy 🎉