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

Plugin does not recurse into Magento subdirectories when assembling schema files #706

Open nwcasebolt opened 4 months ago

nwcasebolt commented 4 months ago

Describe the bug

Magento 2.4.6-p2 defines its own directives (such as @doc and @resolver) at vendor/magento/module-graph-ql/etc/schema.graphqls, but custom project files in app/code show errors on these directives. When I copy Magento's schema file to vendor/magento, these errors resolve. If I place the file in any lower subdirectory, the errors return. The plugin seems unable to assemble schema.graphqls files from subdirectories lower than vendor/magento/. This obtains whether I rely on the plugin's OOB implementation or explicitly configure a basic configuration or composite schema.

To Reproduce

Set Up Initial State

  1. If you don't have a Magento instance installed, you can set up a test environment as follows.
  2. Create a root project directory. Create an app/code directory and a vendor/magento/module-graph-ql directory.
  3. Clone an example Magento 2 module into app/code/. MagePlaza's SMTP-2 module will work.
  4. Copy Magento's GraphQL module into vendor/magento/quote-graph-ql.

OOB Configuration

  1. In PhpStorm, open MagePlaza's schema.graphqls file in etc and observe errors on Magento's directives.

Basic Configuration

  1. Follow the instructions to create an explicit configuration file.
  2. Observe that errors are still thrown in app/code schema files.

Composite Schemas

  1. Follow the instructions to create a composite schema, using the glob pattern to target Magento's vendor directory (or subdirectories) directly.
  2. Observe that errors are still thrown in app/code schema files.

Undesirable Resolution

  1. Move or copy Magento's schema.graphqls file from vendor/magento/quote-graph-ql/etc to vendor/magento.
  2. Observe that there are no further directive errors in MagePlaza's schema file.

Expected behavior The plugin recurses into all project subdirectories and assembles all matching schema files, without resorting to copying Magento's custom schema to a higher directory.

Version and Environment Details Operation system: macOS Sonoma 14.2.1 IDE name and version: PhpStorm 2023.3.4 Plugin version: 233.13135.65

vepanimas commented 4 months ago

Hi @nwcasebolt! You mentioned a glob pattern in the issue title, but I don't see any configs in the provided code or in steps to reproduce. Could you please elaborate?

nwcasebolt commented 3 months ago

Hi @nwcasebolt! You mentioned a glob pattern in the issue title, but I don't see any configs in the provided code or in steps to reproduce. Could you please elaborate?

Certainly, @vepanimas. I see how my title is misleading, since it refers to a specific part of the problem I have rather than the holistic issue. I've modified the title and updated my reproduction steps to be, I hope, more clear.

vepanimas commented 3 months ago

@nwcasebolt Thank you for the clarification! If you stop just after the first step after downloading all the corresponding projects and add no configs at all it will work out of the box. If you create a configuration, I still need to see its content and know the place where you put it, it's important.

For example, if you put such graphql.config.yml in the project root, all directives will be resolved:

schema:
  - app/code/etc/schema.graphqls
  - vendor/magento/module-graph-ql/etc/schema.graphqls
documents: '**/*.graphql'

If you don't want to specify exact paths, this also will work:

schema: '**/*.graphqls'
documents: '**/*.graphql'

or to include not only .graphqls, but also regular .graphql files:

schema: '**/*.graphql*'
documents: '**/*.graphql'