JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Register the embedded JSON schema for .graphqlconfig.yaml files as well #645

Closed james-johnston-thumbtack closed 1 year ago

james-johnston-thumbtack commented 1 year ago

Describe the bug The plugin contains an embedded JSON Schema at https://github.com/JetBrains/js-graphql-intellij-plugin/blob/d3d8d95ed8649d5c1ec0b1422f8a21c60c8ae78d/resources/schemas/graphql-config-schema.json which makes editing the .graphqlconfig files in JSON format really nice.

However, YAML is a better file format because it supports comments. And unfortunately, the embedded JSON schema is only being registered for the JSON files:

https://github.com/JetBrains/js-graphql-intellij-plugin/blob/009e8b15a8694b572d0b6d45d70b3afa7decb23d/src/main/com/intellij/lang/jsgraphql/ide/project/graphqlconfig/javascript/GraphQLConfigJsonSchemaProvider.java#L29-L36

note the constant here:

https://github.com/JetBrains/js-graphql-intellij-plugin/blob/009e8b15a8694b572d0b6d45d70b3afa7decb23d/src/main/com/intellij/lang/jsgraphql/ide/project/graphqlconfig/GraphQLConfigManager.java#L110

It would be nice if the plugin could automatically register its schema for the YAML config files as well.

To Reproduce Link to Repo with Reproduction or Steps to Reproduce:

  1. Create a .graphqlconfig.yaml file and write the configuration in YAML format.
  2. Try any kind of code analysis feature with the file, like autocomplete features, clicking into a part of the schema, etc. It won't work.

Expected behavior The JSON Schema should be loaded and applied to the YAML file, so that code completion works correctly.

Workaround It is possible to manually set up a JSON Schema Mapping for the file, as shown in the screenshot below. Then it works. Of course it would be nice if this was automatic.

Screenshot 2023-02-11 at 11 28 40 PM

Version and Environment Details Operation system: macOS 13.2 IDE name and version: 2022.3.2 Plugin version: 3.4.0 (also bug is clearly in place given above code links that show registration only for JSON config files)

vepanimas commented 1 year ago

Hi! Right now I'm migrating the GraphQL config to the modern version and it will support YAML as the main option for configuration files.

james-johnston-thumbtack commented 1 year ago

Oh that's awesome, I'm happy to hear we are able to do that migration!