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 · 10 comments
Open

config.schema.json not valid #9749

thscott opened this issue Nov 7, 2023 · 10 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

@Parables
Copy link
Contributor

Hello everyone, I am Parables, the author of the flutter-freezed plugin.

TL'DR: I will fix this ASAP

First of all, my sincere apologies for any inconveniences caused by this plugin.
At the time of submitting that PR, I thought the @type doc comment was for Typescript and that is why I used those types there.... I had no idea they were JSON Schema Types.

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?

I felt heart-broken when I read this because at the time I pushed that PR, I was going through some pretty rough times: financial crisis and in order to address that, I was working on multiple gigs, working 24/7, which resulted in my girlfriend leaving me because I didn't have time for her, leading to an emotional breakdown. Someway, somehow, I managed to overcome those issues and preventing a mental breakdown. Still not solved the financial issue, as I am barely employable with my diploma certificate in Computer Science despite the fact that I have over 9 years experience with software development from backend to frontend. Most opportunities are looking for BSc or HND holders. Still open for work, so please reach out if you can help. Currently a teacher in a primary school in a rural area in Ghana earning just a little to keep me from begging people for money while spending close to 85% of that income on building https://schoolman.app (hoping to launch it within Q1 of 2025) .... Sorry, I was getting very emotional on that...

Please expect a fix within the upcoming weeks.

Thanks very much for your patience...

@Parables
Copy link
Contributor

dotansimha/graphql-code-generator-community#892

This should fix it, please let me know if the issue still persists as I am unable to set up a complete dev environment to test it. For future issues, please tag me @Parables for me to get notified about this plugin.

Thanks once again.

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

8 participants