nuxt-codegen
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

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

/nuxt-codegen/

    Package Sidebar

    Install

    npm i nuxt-codegen

    Weekly Downloads

    65

    Version

    1.3.1

    License

    MIT

    Unpacked Size

    61 kB

    Total Files

    10

    Last publish

    Collaborators

    • eugenistoc