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
880 stars 97 forks source link

Problem with multiple projects in the same workspace #660

Closed l0co closed 1 year ago

l0co commented 1 year ago

When using this plugin with multiple projects in a single workspace:

  1. Plugin complaints about re-declaring the same type, regardless they are defined in other projects and not re-declared in the same project.
  2. When you navigate to a given type (GOTO - CTRL+B in linux), plugin can navigate to type with the same name located in a different project.

To reproduce, please create an empty workspace, add two projects, add two schemas in these two separated projects, and add types with the same name to both schemas.

vepanimas commented 1 year ago

@l0co Unfortunately, there are not enough details to understand what's going on. Could you please share your GraphQL config? How do you configure those two projects to separate type definitions from each other?

l0co commented 1 year ago

Under a single workspace you can have multiple projects from different git roots using File | New | Module from existing sources. Eg:

  1. Create a java project
  2. Create another java problem in a different/new workspace
  3. In second java project use "Module from existing source" to add a first project to the workspace.

Another way:

  1. Create a new project/workspace
  2. To the root project dir copy a few other projects (they will be discovered by idea as separate modules)
  3. You now have multi-project workspace
vepanimas commented 1 year ago

The GraphQL plugin does not take module structure into consideration. Instead, it relies solely on the GraphQL config and project layout in the filesystem. For more information, please refer to the documentation.

l0co commented 1 year ago

Thanks. I'm gonna review that if we can use it to prevent from this behavior. But still it looks the default is to merge all (different) project schemas into one schema, what doesn't look like something desired.

vepanimas commented 1 year ago

The plugin works with "scopes," which can be either global (including every GraphQL file under the project root) or restricted by a configuration file. It doesn't consider module structure and relies on the filesystem because it's IDE-agnostic. For example, IDEA/Android Studio, WebStorm, and Rider have significantly different project models. It also should work with different editors and language services, which use the same approach to configuration.

The easiest way in your case is to create an empty graphql.config.yml in every separate module you need.

l0co commented 1 year ago

That's resolves the problem. Thanks :)