Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nwcasebolt opened this issue Mar 6, 2024 · 3 comments

Comments

@nwcasebolt
Copy link

nwcasebolt commented Mar 6, 2024

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
Copy link
Collaborator

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 nwcasebolt changed the title Glob pattern does not recurse into Magento subdirectories when assembling schema files Plugin does not recurse into Magento subdirectories when assembling schema files Mar 7, 2024
@nwcasebolt
Copy link
Author

nwcasebolt commented Mar 7, 2024

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
Copy link
Collaborator

vepanimas commented Mar 7, 2024

@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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants