dotansimha / dotansimha/graphql-code-generator

Multi-project top-level config

Open
#9,598 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Is your feature request related to a problem? Please describe.

I'd like to be able to specify a top-level config to be shared by all projects in a multi-project setup.

### Describe the solution you'd like

```js
/** @type {import('graphql-config').IGraphQLConfig } */
module.exports = {
extensions: {
codegen: {
config: {
avoidOptionals: { field: true }, // Correct nullable field types
defaultScalarType: "unknown",
enumsAsTypes: true, // Prefer string unions
immutableTypes: true, // Prevent components from mutating data
inputMaybeValue: "T | undefined", // Correct optional input types
onlyOperationTypes: true,
useTypeImports: true,
},
},
},
projects: {
prj1: {
schema: ["prj1/**/*.graphql"],
documents: ["prj1/**/*.gql"],
extensions: {
codegen: {
generates: {
"graphqlTypes.ts": {
plugins: ["typescript", "typed-document-node"],
},
},
},
},
},
prj2: {
schema: ["prj2/**/*.graphql"],
documents: ["prj2/**/*.gql"],
extensions: {
codegen: {
generates: {
"graphqlTypes.ts": {
plugins: ["typescript", "typed-document-node"],
},
},
},
},
},
},
};
```

I expect this would first require upstream support from `graphql-config`.

### Describe alternatives you've considered

The workaround right now is to spread a reusable object within the `codegen` config object in each project, but that isn't compatible with JSON config files.

### Is your feature request related to a problem? Please describe.

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.