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

Multiple schema files - "There is already a schema defined" #510

Closed CruseCtrl closed 2 months ago

CruseCtrl commented 2 years ago

Describe the bug I have a primary graphql endpoint which I use in most queries, and a secondary endpoint which I only use for a couple of queries. I have set up my folders as follows:

root/
├── folder-a/
│   └── query-a.ts
├── folder-b/
│   └── query-b.ts
├── other-folder/
|   ├── .graphqlconfig
|   ├── secondary-schema.graphql
|   └── secondary-query.ts
├── .graphqlconfig
└── primary-schema.graphql

The idea is that it will use the secondary schema in the other-folder, and the primary schema everywhere else. This works fine and it's using the correct schema in each case, but I get schema errors saying "There is already a schema defined" and "There is already an operation 'query' defined".

I have also tried setting this up with a single config file using different projects:

{
  "projects": {
    "primary": {
      "excludes": ["other-folder/**"],
      ...
    },
    "secondary": {
      "includes": ["other-folder/**"],
      ...
    }
  }
}

And although this also worked, I still ended up with the same error messages.

Version and Environment Details Operation system: macOS Big Sur 11.6 IDE name and version: PyCharm 2021.2.3 (Professional Edition) Plugin version: 3.0.0

Additional context The code completion and other features of the plugin are all working fine. The only problem is that I'm getting schema errors, so for now I'm just ignoring them

vepanimas commented 2 months ago

If it's still relevant, have you tried doing this using the new graphql-config? The config could be like this, I haven't tested it, so feel free to adjust if needed:

graphql.config.yml

projects:
  other-project:
    schema: other-folder/secondary-schema.graphql
    documents: other-folder/**/*.{graphql,js,ts}
  default:
    schema: primary-schema.graphql
    documents: '**/*.{graphql,js,ts}'

Please note that the order of the projects is important, they are matched from the top.

More docs about configuration are here.