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

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

Open
4 tasks
yoavain-sundaysky opened this issue May 2, 2024 · 1 comment
Open
4 tasks

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

yoavain-sundaysky opened this issue May 2, 2024 · 1 comment

Comments

@yoavain-sundaysky
Copy link

yoavain-sundaysky commented May 2, 2024

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    For example, you can start off by editng the
    'basic' example on Stackblitz.

    Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided

  • 3. A local solution has been provided

  • 4. A pull request is pending review


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:

  • OS: Windows
  • @graphql-eslint/eslint-plugin: 3.20.1
  • Node.js: 18.20.2 (not relevant)

Additional context

yoavain-sundaysky added a commit to yoavain-sundaysky/graphql-eslint that referenced this issue May 2, 2024
* Convert `source.filePath` to its absolute path to be comparable to importPath/filePath on Windows
yoavain-sundaysky added a commit to yoavain-sundaysky/graphql-eslint that referenced this issue May 2, 2024
* Convert `source.filePath` to its absolute path to be comparable to importPath/filePath on Windows
@yoavain-sundaysky
Copy link
Author

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

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

1 participant