dimaMachina / graphql-eslint

ESLint parser, plugin and set rules for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and modern GraphQL tools.
https://the-guild.dev/graphql/eslint
MIT License
779 stars 102 forks source link

require-import-fragment doesn't work on Windows #2276

Open yoavain-sundaysky opened 2 months ago

yoavain-sundaysky commented 2 months ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

When running on windows, the comparison done between the import absolute path and the available fragments paths is incorrect. The fragmentsFromSiblings returned from siblings.getFragment(fragmentName) is in the format: C:/path/to/file/fragment.graphql While the calculated absolute path of the import in C:\path\to\file\fragment.graphql

Therefore, this comparison always fails.

source.filePath === importPath

A possible fix can be converting the source.filePath (in 2 places):

path.resolve(source.filePath) === importPath

I will try to open a PR to fix this. Not sure how to add a test though...

To Reproduce Steps to reproduce the behavior:

Expected behavior

Environment:

Additional context

yoavain-sundaysky commented 2 months ago

An alternative would be to change the filePath formatting in the getFragments function itself, but I'm not sure what would be affected by such a change