GraphQL Code Generator module for Nuxt3 / Nuxt Bridge.
- Add
nuxt-graphql-codegen
dependency to your project
# Using yarn
yarn add -D nuxt-graphql-codegen
# Using npm
npm install --save-dev nuxt-graphql-codegen
Note you also need graphql
, @graphql-codegen/cli
and the plugins you want to use.
- Add
nuxt-graphql-codegen
to themodules
section of yournuxt.config.ts
import { defineNuxtConfig } from "nuxt";
export default defineNuxtConfig({
modules: ["nuxt-graphql-codegen"],
});
- Create your
codegen.yml
orcodegen.json
configuration file in the project'srootDir
with the Initialization Wizard or manually
yarn graphql-codegen init
That's it! The code generator will now be executed before each build, it will also watch for changes in .graphql
and .gql
files in development mode.
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
modules: ["nuxt-graphql-codegen", {
/**
* @default false
*/
devOnly: boolean;
/**
* @default ['.graphql', '.gql']
*/
extensions: string[];
}],
});
- Run
npm run dev:prepare
to generate type stubs. - Use
npm run dev
to start playground in development mode.