Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.schema.json not valid #9749

Open
thscott opened this issue Nov 7, 2023 · 8 comments
Open

config.schema.json not valid #9749

thscott opened this issue Nov 7, 2023 · 8 comments
Labels
stage/0-issue-prerequisites Needs more information before we can start working on it

Comments

@thscott
Copy link

thscott commented Nov 7, 2023

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:

"type": "{(boolean | DartIdentifierCasing)}",

@Urigo
Copy link
Collaborator

Urigo commented Nov 19, 2023

@thscott thanks for reporting!
Can you share an example or a reproduction of how it looks on your machine?

@Urigo Urigo added the stage/0-issue-prerequisites Needs more information before we can start working on it label Nov 19, 2023
@bradskuse
Copy link

bradskuse commented Nov 29, 2023

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"
  }
}

@Urigo
Copy link
Collaborator

Urigo commented Dec 2, 2023

@bradskuse can you share a repo or a codesandbox with the whole code?

@thscott
Copy link
Author

thscott commented Dec 4, 2023

With only the YAML extension installed, this is what I see:

codegen

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.

@leah-willett-ck
Copy link

I'm having the same issue.

@pete-otaqui
Copy link

This seems to have been introduced in dotansimha/graphql-code-generator-community#47

@kevinvalk
Copy link

All properties of the FlutterFreezedPluginConfig object use type values that are not valid JSON schema types.
image

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?

@samjcombs
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/0-issue-prerequisites Needs more information before we can start working on it
Projects
None yet
Development

No branches or pull requests

7 participants