Skip to content

fix "Unknown fragment" validation error - #3861

Merged
acao merged 4 commits into
graphql:mainfrom
motemen:lsp-fix-unknown-fragment-3620
Mar 14, 2025
Merged

acao merged 4 commits into
graphql:mainfrom
motemen:lsp-fix-unknown-fragment-3620

Conversation

@motemen

@motemen motemen commented Feb 5, 2025

Copy link
Copy Markdown
Contributor

fixes #3620

Above error occurs because it tries to parse already-parsed GraphQL documents as languages like TypeScript or so. This PR fixes this behavior.

@changeset-bot

changeset-bot Bot commented Feb 5, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec08bb7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
graphql-language-service-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@linux-foundation-easycla

linux-foundation-easycla Bot commented Feb 5, 2025 •

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@wenchienchen-asana

Copy link
Copy Markdown

@acao @dimaMachina apologies for the tag, but is there anything non-maintainers can do to help get this fix merged and released? I believe this fixes a longstanding issue that has prevented many people from using the latest version of the VS Code plugin. Thanks!

@VinceBT-BG

Copy link
Copy Markdown

@wenchienchen-asana Can you take a look at the two check errors ?

@wenchienchen-asana

wenchienchen-asana commented Feb 21, 2025 •

Copy link
Copy Markdown

I don't think they're related to this change... The Jest tests pass when I run them locally, so maybe they're flaky or there's some issue specific to the CI setup?

@acao

acao commented Feb 27, 2025 •

Copy link
Copy Markdown
Contributor

I am also getting test failures as well, it seems that there were some changes to to the integration tests since I last worked on them and they are failing for me locally and in CI here. The fs mocking appears to be the culprit, which can be quite flaky. Thus this nonsensical error, which was fixed last year:

  EEXIST, file already exists '/tmp/graphql-language-service'

      141 |
      142 |     if (!existsSync(this._tmpDirBase)) {
    > 143 |       void mkdirSync(this._tmpDirBase);
          |                     ^
      144 |     }
      145 |   }

The change makes sense, but I need to get these tests working, because these tests are already designed to test for this bug, if you see the other fragment related tests in this file!

update: good news!

it appears related to this issue:
tschaub/mock-fs#380

funny thing, in MessageProcessor.ts if i just change the existsSync import from node:fs to fs, the tests pass, including yours!

@dimaMachina are we going to run into runtime/build issues if we change from node:fs to fs to import in this one file? perhaps we should patch fs-mock if so?

@acao

acao commented Feb 27, 2025 •

Copy link
Copy Markdown
Contributor

@motemen I've confirmed the fix behaviorally, and the new test fails if I revert the change, looks awesome!

the fix for mock-fs should pass in CI i hope, the delta may be node version related

@acao

acao commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

no dice on that fixing CI as you can see 😭
I hope to fix this over the weekend. hopefully it's just a node version issue. we may just replace the mock-fs impl with something more stable, as this should not be this hard 😆

I would otherwise just skip the test because this bug is so important to fix, but this integration suite is very important, so I need to give this my due diligence!

@acao

acao commented Mar 14, 2025 •

Copy link
Copy Markdown
Contributor

I am going to go ahead and merge this with a failing test, because this bugfix is more important than the test currently, and I can confirm that the new test works and confirms the bugfix. I will take care of solving this test bug as a follow up after the next release. thanks everyone for your patience, and @motemen for this fix!

motemen and others added 4 commits March 13, 2025 22:00
`mock-fs` uses `process.binding('fs')`, so it cannot support mocking the `node:fs` import alias it seems. this should fix test failures in CI (for node 22 at least)
@acao
acao force-pushed the lsp-fix-unknown-fragment-3620 branch from 9975944 to ec08bb7 Compare March 14, 2025 02:00
@acao
acao merged commit c5325dd into graphql:main Mar 14, 2025
@acao acao mentioned this pull request Mar 14, 2025
@acao

acao commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

oddly enough, the test passed here
https://github.com/graphql/graphiql/actions/runs/13848401899/job/38751280571?pr=3881

PASS graphql-language-service-server packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts (44.561 s)

either way, enjoy the latest release! thanks again!

@motemen

motemen commented Mar 14, 2025

Copy link
Copy Markdown
Contributor Author

Thank you!

@VinceBT-BG

VinceBT-BG commented Mar 14, 2025 •

Copy link
Copy Markdown

@acao Should it fix #3066 as well ?

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

Successfully merging this pull request may close these issues.

[lsp-server] 🐞 VSCode validation error Unknown fragment in v0.11.0

4 participants