dotansimha / dotansimha/graphql-code-generator
[Feature] Support YAML anchors
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
I have this code with a couple of modules, but I plan to expand to many more modules, and already they're getting repetetive in the plugins block at least. I'd like to see [yaml](https://yaml.org/spec/1.2/spec.html#id2765878) [anchors](https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/) [supported](https://medium.com/@kinghuang/docker-compose-anchors-aliases-extensions-a1e4105d70bd) here's a list of officially recommended parsers that support them (I'm not sure how you're parsing now) https://yaml.org scroll down to Javascript, both `yaml` and `js-yaml` are available via npm
```yaml
overwrite: true
require:
- ts-node/register
config:
useTypeImports: true
scalars:
DateTime: "@js-joda/core#ZonedDateTime"
Date: "@js-joda/core#LocalDate"
generates:
packages/apollo/src/generated/schema.ts:
schema:
- packages/apollo/src/**/*.schema.graphql
- packages/apollo/src/**/*.test-schema.graphql
documents: packages/apollo/src/**/*.test.graphql
plugins:
- typescript
- typescript-resolvers
- typescript-operations
- typescript-document-nodes
packages/app/src/generated/schema.graphql:
schema: packages/*/src/**/*.schema.graphql
plugins:
- schema-ast
packages/app/src/generated/schema.ts:
schema: packages/*/src/**/*.schema.graphql
documents: packages/app/src/**/*.test.graphql
plugins:
- typescript
- typescript-resolvers
- typescript-operations
- typescript-document-nodes
config:
noSchemaStitching: true
contextType: ../shared/graphql#Context
defaultMapper: Partial<{T}>
mappers:
```
I'd rather rewrite it like this
```yaml
configs:
tsfile: &ts-schema
plugins:
- typescript
- typescript-resolvers
- typescript-operations
- typescript-document-nodes
overwrite: true
require:
- ts-node/register
config:
useTypeImports: true
scalars:
DateTime: "@js-joda/core#ZonedDateTime"
Date: "@js-joda/core#LocalDate"
generates:
packages/apollo/src/generated/schema.ts:
<<: *ts-schema
schema:
- packages/apollo/src/**/*.schema.graphql
- packages/apollo/src/**/*.test-schema.graphql
packages/app/src/generated/schema.graphql:
schema: packages/*/src/**/*.schema.graphql
plugins:
- schema-ast
packages/app/src/generated/schema.ts:
<<: *ts-schema
schema: packages/*/src/**/*.schema.graphql
config:
```
```
> npx envinfo --preset jest # services -> feature/RS2-1243-logging $ ! RC=1
npx: installed 1 in 1.461s
System:
OS: macOS 10.15.6
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Binaries:
Node: 12.18.3 - /usr/local/bin/node
Yarn: 2.3.0 - /usr/local/bin/yarn
npm: 6.14.6 - /usr/local/bin/npm
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.