Skip to content

Integrates graphql-codege-generator into the Nuxt development flow

License

Notifications You must be signed in to change notification settings

genu/nuxt-codegen

Repository files navigation

nuxt-codegen

This module integrates GraphQL Code Generator in your development flow.

Quick setup

  1. 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
  1. Add nuxt-codegen to the modules section of nuxt.config.ts
export default defineNuxtConfig({
    modules: ['nuxt-codegen']
})

Note you also need graphql, and the plugins you want to use.

  1. Create your codegen.ts configuration file in the project's rootDir or use the Initialization Wizard

The code generator will now be executed before each build or after any changes made to your graphql documents.

Configuration

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
  }],
});

Prior art

Development

  1. Clone this repository
  2. Install dependencies using pnpm pnpm install
  3. Prepare for development using pnpm dev:prepare
  4. Start development server using pnpm dev

About

Integrates graphql-codege-generator into the Nuxt development flow

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published