This module integrates GraphQL Code Generator in your development flow.
- Add
nuxt-codegen
dependency to your project
# Using yarn
yarn add nuxt-codegen -D
# Using npm
npm install nuxt-codegen -D
# Using pnpm
pnpm add nuxt-codegen -D
- Add
nuxt-codegen
to the modules section ofnuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-codegen']
})
Note you also need graphql
, and the plugins you want to use.
- Create your
codegen.ts
configuration file in the project'srootDir
or use the Initialization Wizard
The code generator will now be executed before each build or after any changes made to your graphql documents.
export default defineNuxtConfig({
modules: ["nuxt-codegen", {
/**
* @default true
* Only run codegen in development mode
*/
devOnly: boolean;
/**
* @default ['.graphql', '.gql']
* Which file extensions to watch for changes.
*/
extensions: string[];
/**
* @default codegen.ts
* Path to the config file (e.g. ./configs/codegen.config.ts)
*/
configFile: string
}],
});
- Clone this repository
- Install dependencies using pnpm
pnpm install
- Prepare for development using
pnpm dev:prepare
- Start development server using
pnpm dev