graphql-code-generator
graphql-code-generator copied to clipboard
config.schema.json not valid
The json schema config.schema.json seems to be invalid, so is causing issues in vscode (which tries to validate the codegen.yml file).
This seems to be due to the property types of the FlutterFreezedPluginConfig being invalid, such as: https://github.com/dotansimha/graphql-code-generator/blob/527da03f1ecbf8de12259342386551792656a8e9/website/public/config.schema.json#L111
@thscott thanks for reporting! Can you share an example or a reproduction of how it looks on your machine?
Hey @Urigo , I have this same issue. Here is the contents of my codegen.yml
schema: './schema.graphql'
generates:
./src/__generated__/resolvers-types.ts:
plugins:
- 'typescript'
- 'typescript-resolvers'
config:
useIndexSignature: true
contextType: '../index#MyContext'
package json:
{
"name": "graphql-server-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"generate": "graphql-codegen --config codegen.yml",
"compile": "npm run generate && tsc",
"postinstall": "npm run compile",
"start": "npm run compile && node ./dist/index.js",
"watch": "concurrently --names \"CodeGen,TS,Nodemon\" -c \"bgYellow,bgBlue,bgMagenta\" \"graphql-codegen --watch 'src/**/*.ts'\" \"tsc -w \" \"nodemon ./dist/index.js \""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@apollo/server": "^4.9.5",
"graphql": "^16.8.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-resolvers": "^4.0.1",
"@types/node": "^20.10.0",
"concurrently": "^8.2.2",
"nodemon": "^3.0.1",
"typescript": "^5.3.2"
}
}
@bradskuse can you share a repo or a codesandbox with the whole code?
With only the YAML extension installed, this is what I see:
This extensions gets its schemas from a catalogue, for which the default is https://www.schemastore.org/api/json/catalog.json.
This in turn points to https://the-guild.dev/graphql/codegen/config.schema.json, which contains (the seemingly invalid) FlutterFreezedPluginConfig properties.
I'm having the same issue.
This seems to have been introduced in https://github.com/dotansimha/graphql-code-generator-community/pull/47
All properties of the FlutterFreezedPluginConfig
object use type values that are not valid JSON schema types.
The configuration types are "better" explained in the current documentation https://the-guild.dev/graphql/codegen/plugins/dart/flutter-freezed (or just https://github.com/dotansimha/graphql-code-generator-community/blob/b6c4b0159c53530251dc50040eeac282f6e128e9/packages/plugins/dart/flutter-freezed/src/config/plugin-config.ts). However, they feel "weird" and out of place compared to all other plugins.
The schema has to be updated to reflect the more complex types. For example, for camelCasedEnums
it should be as below (OR rewritten using "$ref" and keeping the DartIdentifierCasing
.
"FlutterFreezedPluginConfig": {
"description": "configure the `flutter-freezed` plugin",
"type": "object",
"properties": {
"camelCasedEnums": {
"anyOf": [{"type": "boolean"}, {"type": "string", "enum": ["snake_case", "camelCase", "PascalCase"]}],
"description": "Setting this option to `true` will camelCase enum values as required by Dart's recommended linter.\n\nIf set to false, the original casing as specified in the Graphql Schema is used\n\nYou can also transform the casing by specifying your preferred casing for Enum values.\n\nAvailable options are: `'snake_case'`, `'camelCase'` and `'PascalCase'`\n\nFor consistency, this option applies the same configuration to all Enum Types in the GraphQL Schema\nDefault value: \"true\""
},
That said, I am not sure who "owns" the schema nor how to manage the schema + docs complex types.
Until this is fixed the schema is literally unusable, so perhaps yanking the FlutterFreezedPluginConfig
from the schema is the best interim solution?
Until this is fixed the schema is literally unusable, so perhaps yanking the FlutterFreezedPluginConfig from the schema is the best interim solution?
+++
I'm seeing the same issue