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

Schema file can't exist in "hidden" folders #673

Open Zn4rK opened 1 year ago

Zn4rK commented 1 year ago

Schema file can't exist in "hidden" folders.

To Reproduce Place a schema in a folder starting with a dot. For example:

Schema location:

.mesh/schema.graphql

graphql.config.yml

schema: './.mesh/schema.graphql'

Expected behavior This should be possible. It was possible in the previous major version. The plugin should not have any opinions on the project structure.

It only find the built-ins from "Specification.graphql": image

Browsing the schema results in: image (Red means "not found")

Moving the schema file out of the "hidden" folder, it works as expected: image

Screenshots Manual selection of directory: Screenshot 2023-06-14 at 12 02 03 Project structure: Screenshot 2023-06-14 at 12 02 11

Version and Environment Details Operation system: macOS Monterey 12.6.5 IDE name and version: Webstorm Build #WS-231.8770.64, built on April 27, 2023 Plugin version: 4.0.1

Additional context This worked in the previous major version.

arm1n commented 11 months ago

I am experiencing the same in my Gatsby project locating schema definition files inside .cache folder.

vepanimas commented 10 months ago

@Zn4rK hi! I created a simple project with schema inside of a folder whose name starts with a dot and it works for me 🤷‍♂️

dot-folder-graphql-schema

Please, check that your folders are not marked as "Excluded".

Zn4rK commented 10 months ago

Please, check that your folders are not marked as "Excluded".

It's marked as excluded, but I don't want to cancel exclusion, since it's re-generated very often, and doesn't need to be in the index. It did work in a the previous major version of the plugin. Nothing has changed in my setup other than this plugin.

arm1n commented 10 months ago

I've not excluded it in the config file and it's still behaving differently as in previous versions. Something must have changed in the last major upgrade.

vepanimas commented 10 months ago

@Zn4rK if a file is excluded it's not indexed and now won't be used by the plugin, that's how directory exclusion works for every IDE, otherwise, what's the point of excluding a directory? You do that if you don't want symbols from that folder/file/library to appear in code completion/documentation/resolve/etc, and that's exactly what happens here.

@arm1n GraphQL configuration management is rewritten from scratch in the latest major update during migration to the graphql-config v3 standard, something could be broken or work in a bit different way. Though it is still expected to be backward compatible, especially for small projects with trivial configurations. Probably, docs about migration could answer some questions, otherwise feel free to open an issue with your project configuration and I'll try to help you 🙏

EDIT: initial link to migration docs was incorrect, the docs are here https://github.com/JetBrains/js-graphql-intellij-plugin#migration

arm1n commented 10 months ago

@vepanimas Thanks for the quick answer. The graphql config is automatically generated by Gatsby and looks like:

{
  "schema": ".cache/typegen/schema.graphql",
  "documents": [
    "src/**/**.{ts,js,tsx,jsx}",
    ".cache/typegen/fragments.graphql"
  ],
  "extensions": {
    "endpoints": {
      "default": {
        "url": "http://0.0.0.0:8000/___graphql"
      }
    }
  }
}

But it's unable to find the schema definitions since the last update as stated in the description of this ticket. So there's no excludes in place. Any idea what's wrong here?

Zn4rK commented 10 months ago

You do that if you don't want symbols from that folder/file/library to appear in code completion/documentation/resolve/etc, and that's exactly what happens here.

I mean, I understand your point - but in the GraphQL-ecosystem, does this make sense? I want to exclude all autogenerated files. I don't use these in my sources. That's why I've excluded them. The .mesh-folder also contains a bunch of other stuff that's actually changing on me, and that I don't care about at all. I'm fine with not excluding the schema file specifically, but that's not possible with WebStorm.

The workaround I have right now is to specify a schema with a url instead which uses the .mesh-schema. The plugin then executes an introspection query, and gets the schema from that. I wish that the resolution of excluded files could work similarly to that.

vepanimas commented 10 months ago

@arm1n schema discovery for Gatsby projects looks completely broken 😢 Created an issue https://github.com/JetBrains/js-graphql-intellij-plugin/issues/683, I'll try to fix it ASAP.

vepanimas commented 10 months ago

@Zn4rK

I'm fine with not excluding the schema file specifically, but that's not possible with WebStorm.

yep, that's actually a big problem, I can imagine a case when you exclude a whole folder but you still need some files inside.

One interesting question is why it worked before as you said. Because AFAIK we have this issue for years already https://github.com/JetBrains/js-graphql-intellij-plugin/issues/334.

I'll think about that again, it's tricky to make all the functionality including file watchers, virtual file system, caches, etc to work correctly when a directory is excluded, probably I'll introduce some workaround for that.

arm1n commented 10 months ago

@arm1n schema discovery for Gatsby projects looks completely broken 😢 Created an issue #683, I'll try to fix it ASAP.

Thank you very much for looking into this!