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

fix(graphqlsp): Bail out of unrollFragment infinite loop #347

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/graphqlsp/src/ast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ function unrollFragment(
// If we found another identifier, we repeat trying to find the original
// fragment definition
if (ts.isIdentifier(found)) {
// NOTE: A gotcha of `getDefinitionAtPosition` is that when resolution fails, it points
// back at the original identifier (e.g. if its of the internal type `error`).
if (found === element) {
// TODO: Instead of bailing out here, we should be able to issue a diagnostic here
// that tells the user that resolution of a fragment has failed.
return fragments;
Copy link
Member

@JoviDeCroock JoviDeCroock Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a throws argument or something so we can throw if need be from the CLI

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re. notes in PR description, I don't think this is really safe to merge, but instead more for "notes" so I can come back to it 😄
There's several cases where I think similar issues can happen, and there's not really a great option to addressing most of them right now, until we can escalate granular errors, otherwise we basically end up either hiding the issue from the user and it'll only become apparent when they check output (or not at all) or we'd be taking debug info away from ourselves 🤔

}
return unrollFragment(found, info, typeChecker);
}

Expand Down