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

after 4.0.0 upgrade, tracking multiple schemas is no longer working #654

Closed xxx closed 1 year ago

xxx commented 1 year ago

Heya, thanks for this plugin.

After updating to 4.0.0, our gql documents were no longer being linked to the schema. After adding a documents field to graphql.config.yml, they are correctly seen, but we also track the Linear API schema in our graphql config, and now the files that are included in that schema are no longer seen. Without the documents field on our main schema, these are seen as expected.

To Reproduce

projects:
  DoubleLoop:
    schema: schema.graphql
#    documents: '**/*.graphql'
    exclude:
      - linear-schema.graphql
      - '**/app/services/api/linear_api.rb'
    extensions:
      endpoints:
        Default GraphQL Endpoint:
          url: http://localhost:3000/graphql
          headers:
            user-agent: JS GraphQL
          introspect: false
  Linear-GraphQL:
    schema: linear-schema.graphql
    documents: []
    include: '**/app/services/api/linear_api.rb'
    exclude: '*'
    extensions:
      endpoints:
        Linear API Endpoint:
          url: https://api.linear.app/graphql
          headers:
            user-agent: JS GraphQL
            Authorization: ${LINEAR_API_KEY}
          introspect: true

with this config, the 2 files excluded in the DoubleLoop schema no longer get picked up by the Linear-GraphQL schema.

with the previous version .graphqlconfig:

{
  "projects": {
    "DoubleLoop": {
      "name": "DoubleLoop GraphQL Schema",
      "schemaPath": "schema.graphql",
      "excludes": ["linear-schema.graphql", "**/services/api/linear_api.rb"],
      "extensions": {
        "endpoints": {
          "Default GraphQL Endpoint": {
            "url": "http://localhost:3000/graphql",
            "headers": {
              "user-agent": "JS GraphQL"
            },
            "introspect": false
          }
        }
      }
    },
    "Linear-GraphQL": {
      "name": "Linear GraphQL Schema - GraphQL format",
      "schemaPath": "linear-schema.graphql",
      "excludes": ["*"],
      "includes": ["**/app/services/api/linear_api.rb"],
      "extensions": {
        "endpoints": {
          "Linear API Endpoint": {
            "url": "https://api.linear.app/graphql",
            "headers": {
              "user-agent": "JS GraphQL",
              "Authorization": "${env:LINEAR_API_KEY}"
            },
            "introspect": true
          }
        }
      }
    }
  }
}

everything works as expected.

Expected behavior I expect that adding the documents field on our main schema will not invalidate files included with the other, or that the migrated configuration would just work.

Version and Environment Details Operation system: Ubuntu 22.04.2 IDE name and version: RubyMine 2023.1 Plugin version: 4.0.0

vepanimas commented 1 year ago

@xxx Hello! I have a few questions regarding your GraphQL project. Does it work as expected with .graphqlconfig in the latest update (4.0.0), or only in the previous version?

Can you provide more information about your project structure? How are the files separated between schemas? The usage of exclude: '*' seems a bit odd. Why is it necessary?

Additionally, could you try using this code snippet to see if it works for your project setup?

projects:
  DoubleLoop:
    schema: schema.graphql
  Linear-GraphQL:
    schema: linear-schema.graphql
    documents: ['**/app/services/api/linear_api.rb']

The code should associate all SDLs from schema.graphql with the DoubleLoop project, and all SDLs from linear-schema.graphql and operations from **/app/services/api/linear_api.rb with the Linear-GraphQL project. Any other operations in non-matching files will be associated with the first project implicitly, which is DoubleLoop in this case. Is this what you need?

xxx commented 1 year ago

Hello - thank you for responding.

I can confirm that the .graphqlconfig works correctly with 4.0.0.

As far as the project structure goes, it's a standard Rails project. We just happen to be interacting with the Linear API, and we want that specific file to be checked against their schema, while every other file is checked against ours (i.e. exactly what you mentioned above.)

The snippet above does do exactly what I'm after. Thanks!

The exclude '*' was there just because with everything else, it was needed. It was during a 'try anything at all to see if it works' scenario when I was first setting it up last year.