dotansimha / dotansimha/graphql-code-generator

Support custom schema loader options

Open
#10,236 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 want to create a custom schema loader, where I first pre-filter and prune schema before generating code files

However currently the only option - is to give a string with the loader name

So what I miss now - is the ability to give custom options, for example array of types to filter or whatever I want.

In the documentation example is recommended to read config from the loader - however i just thought that would be convenient to keep all in one place

### Describe the solution you'd like

I'd like to use something like this:

```
const config: CodegenConfig = {
overwrite: true,
schema: {
"https://gitlab.com/api/graphql": {
loader: './schema-loader.ts',

// here we define a custom config
config: {
filterQueries: ['project']
}
}
},
...
}
};

export default config;
```

Alternatively and is probably even better would be option to give the instance of the loader. In this case we can inititalize it before.

If we have already option to provide the instance for document transformation - why not to introduce something to transform the schema, or at least to load it with a code.

### Describe alternatives you've considered

_No response_

### Any additional important details?

_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.