YAML schema is incorrect
See original GitHub issueDescribe the bug
When using the VSCode (version 1.70 YAML extension redhat.vscode-yaml
(version 1.9.1), it considers the config.schema.json
as invalid due to the use of string[]
as value in the type
field.
Schema 'GraphQL Code Generator (config.schema.json)' is not valid:
/definitions/TypeGraphQLPluginConfig/properties/decorateTypes/type : must be equal to one of the allowed values
/definitions/TypeGraphQLPluginConfig/properties/decorateTypes/type : must be array
/definitions/TypeGraphQLPluginConfig/properties/decorateTypes/type : must match a schema in anyOfYAML(768)
"TypeGraphQLPluginConfig": {
"type": "object",
"properties": {
"decoratorName": {
"$ref": "#/definitions/Partial_1",
"description": "allow overriding of TypeGraphQL decorator types\nDefault value: \"{ type: 'ObjectType', interface: 'InterfaceType', arguments: 'ArgsType', field: 'Field', input: 'InputType' }\""
},
"decorateTypes": {
"description": "Specifies the objects that will have TypeGraphQL decorators prepended to them, by name. Non-matching types will still be output, but without decorators. If not set, all types will be decorated.",
"type": "string[]"
},

Reference https://www.graphql-code-generator.com/docs/config-reference/codegen-config
Additionally, when I overrode it and fixed that string[]
locally, it had another issue where top level config values had to be objects:

Which is exactly what the example docs say they support.
"__type": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/T"
}
},
"T": {
"type": "object"
},
"Types.PluginConfig": {
"$ref": "#/definitions/__type"
},
Your Example Website or App
https://www.graphql-code-generator.com/config.schema.json
Steps to Reproduce the Bug or Issue
I don’t have a link to a repo because I don’t think it is relevant.
Try to create a codegen.yml
file in VSCode while using the YAML extension.
Expected behavior
The schema to be valid.
Screenshots or Videos


Platform
- OS: [e.g. macOS, Windows, Linux]
- NodeJS: 14.20.0
graphql
version: 16.5.0@graphql-codegen/*
version(s): “@graphql-codegen/add”: “^3.2.0”, “@graphql-codegen/cli”: “^2.6.2”, “@graphql-codegen/introspection”: “^2.1.1”, “@graphql-codegen/typescript”: “^2.5.0”, “@graphql-codegen/typescript-graphql-request”: “^4.4.11”, “@graphql-codegen/typescript-operations”: “^2.4.1”,
VSCode output: Version: 1.70.0 (Universal) Commit: da76f93349a72022ca4670c1b84860304616aaa2 Date: 2022-08-04T04:38:55.829Z (5 days ago) Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Darwin arm64 21.6.0
YAML extension: 1.9.1
Also tested on YAML extension 1.7.0 with the same results.
Codegen Config File
Doesn’t actually matter what the YML is, so here are the first few lines:
config:
avoidOptionals:
field: true
inputValue: false
object: true
defaultValue: true
# Use Unions instead of Enums
enumsAsTypes: true
Additional context
https://www.graphql-code-generator.com/config.schema.json
Search for string[]
Search for “T”
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
I don’t think this is an acceptable workaround since it requires to have the schema locally…
I created a PR for this here: https://github.com/dotansimha/graphql-code-generator/pull/8233
The problem was
@type
was specified in the JSDoc (and not in any of the other workingstring[]
places), which overrides the type thattypescript-schema-generator
uses to generate the schema.