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

Gatsby graphql.config.json is not found #683

Open
vepanimas opened this issue Aug 11, 2023 · 10 comments
Open

Gatsby graphql.config.json is not found #683

vepanimas opened this issue Aug 11, 2023 · 10 comments
Labels

Comments

@vepanimas
Copy link
Collaborator

Schema is not discovered for Gatsby projects when graphqlTypegen: true is enabled in gatsby-config.js.

Reported here #673 (comment).

@vepanimas vepanimas added the bug label Aug 11, 2023
intellij-monorepo-bot pushed a commit that referenced this issue Aug 17, 2023
GitOrigin-RevId: 9c8ea0f7699b0269b7c9ad3418822c66998ea6f6
@vepanimas
Copy link
Collaborator Author

vepanimas commented Aug 18, 2023

@arm1n hey, could you please try a new plugin build with the fix? Does it fix the problem? Please, note that Gatsby expects you to create a graphql.config.js in the root of the Gatsby project, it's the same folder that contains the .cache dir. [docs]

js-graphql-intellij-plugin-4.0.2.zip

@arm1n
Copy link

arm1n commented Aug 18, 2023

Hey @vepanimas thanks for providing a fix for this, I can confirm that it's working with the 4.0.2 and adding a graphql.config.js in the root of the project.

@robclancy
Copy link

robclancy commented Sep 25, 2023

This is not fixed in the released 4.0.2.

EDIT: I also installed from the zip here and it didn't work.

It's not working when the folder is excluded... it shouldn't be a surprise that an auto generated file that only works with a specific plugin might be excluded.

@vepanimas
Copy link
Collaborator Author

It's not working when the folder is excluded... it shouldn't be a surprise that an auto generated file that only works with a specific plugin might be excluded.

@robclancy Why do you think it should be excluded?

@robclancy
Copy link

It's a cache and tmp folder...

@vepanimas
Copy link
Collaborator Author

vepanimas commented Oct 15, 2023

@robclancy Yep, it's correct, though, why do you need to exclude it? You usually exclude a folder if you don't want the files inside of it to be indexed and to appear in completion, resolve, navigation, etc. Nevertheless, we do have an issue related to that, but it's not yet clear when it will be implemented.

From the IntelliJ IDEA docs:

Files in excluded folders are ignored by code completion, navigation and inspection. That is why when you exclude a folder that you don't need at the moment, you can increase the IDE performance. Normally, compilation output folders are marked as excluded.

Apart from excluding the entire folders, you can also exclude specific files.

To sum things up, generated != excluded.

@robclancy
Copy link

What are you talking about? A tmp and cache folder is always excluded. A tmp folder is used for generated files. This issue is not resolved because if you exclude the folder that you should be excluding, the entire reason for the exclude feature to exist, then gatsby graphql config does not work.

@vepanimas
Copy link
Collaborator Author

What are you talking about?

Look, when you want a file to be excluded from indexing, you mark it or the whole folder as excluded. That's what is written in the docs I provided. For some technologies, e.g. node.js and its node_modules, we have some workarounds, that allow us to use excluded files for completion and resolve, but usually, when you exclude something, it's completely ignored by the IDE.

The easiest way for now to bypass that and leave the .cache folder excluded is to un-exclude a specific directory you need, for Gatsby it is .cache/typegen.

gatsby-exclusion.mp4

@robclancy
Copy link

Nothing you have said has contradicted anything I have said. I have no idea why you are saying these things.

@jeron-diovis
Copy link

jeron-diovis commented Jan 3, 2024

I was wondering why it doesn't work, and it appears that it's because of a hidden directory (#673).
I managed to get it working with a workaround:

  • make a symlink to .cache/typegen/schema.graphql in root folder
  • copy graphql.config.json from .cache/typegen to root folder. Config is very simple, and copypasting it is not a big deal.
  • set schema field in config to schema.graphql

And voila, webstorm recognizes my queries now.
If you don't want to commit symlinks, link can be renamed like schema.local.graphql and added to gitignore.

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

No branches or pull requests

4 participants