🛩 A cool and opinionated base configuration for Graphql Code Generator.
- Generates a base
schema.graphql
file using@graphql-codegen/schema-ast
- Generates a base
schema.generated.ts
with typings for the base schema using@graphql-codegen/typescript
- Generates typings files for each of your operations files using
@graphql-codegen/typescript
- Generate
TypedDocumentNode
instead of hooks/composables using@graphql-codegen/typed-document-node
- Use PascalCase as default naming convention.
- Remove
__typenames
from types.
pnpm add -D @julr/gql-generator-full-blown-preset
pnpm add @graphql-typed-document-node/core
If you are using pnpm you must hoist the @graphql-codegen
dependencies to the root modules directory. This could be done by adding the following content to your project .npmrc file :
public-hoist-pattern[]=@graphql-codegen/*
Create a graphql.config.js
file in the root of your project.
require("dotenv").config();
const defineConfig = require("@julr/gql-generator-full-blown-preset");
module.exports = defineConfig({
// The path to your GraphQL schema file. Can be a local file or a remote URL.
schema: {
url: process.env.HASURA_URL,
secret: process.env.HASURA_SECRET,
},
// Since we're using graphql-config, you may need to define
// additional extensions configurations
additionalExtensions: {
myExtension: {
config: 'foo'
}
}
});
MIT License © 2022 Julien Ripouteau