0.3.3 • Published 3 years ago
nuxt-graphql-codegen v0.3.3
nuxt-graphql-codegen
GraphQL Code Generator module for Nuxt3 / Nuxt Bridge.
Quick setup
- Add
nuxt-graphql-codegendependency to your project
# Using yarn
yarn add -D nuxt-graphql-codegen
# Using npm
npm install --save-dev nuxt-graphql-codegenNote you also need graphql, @graphql-codegen/cli and the plugins you want to use.
- Add
nuxt-graphql-codegento themodulessection of yournuxt.config.ts
import { defineNuxtConfig } from "nuxt";
export default defineNuxtConfig({
modules: ["nuxt-graphql-codegen"],
});- Create your
codegen.ymlorcodegen.jsonconfiguration file in the project'srootDirwith the Initialization Wizard or manually
yarn graphql-codegen initThat'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.
Configuration
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
modules: ["nuxt-graphql-codegen", {
/**
* @default false
*/
devOnly: boolean;
/**
* @default ['.graphql', '.gql']
*/
extensions: string[];
}],
});Development
- Run
npm run dev:prepareto generate type stubs. - Use
npm run devto start playground in development mode.