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: Remove generic constraint on graphql.scalar’s type name to improve performance #53

Merged
merged 4 commits into from
Feb 3, 2024

Conversation

kitten
Copy link
Member

@kitten kitten commented Feb 3, 2024

Resolves #47

Summary

Retrieving a large union of type names and then potentially exposing the tsserver to it seems to cause a crash. Furthermore, evaluating the schema to retrieve all types, filter them by their kind, and then extracting the names seems to also cause issues.

I noticed that auto-complete in place of a generic isn't possible anyway, so we can save ourselves the effort. We can potentially readd it to the graphql.scalar argument itself, but it doesn't really seem worth it.

Set of changes

  • Remove getScalarTypeNames
  • Remove type names constraint from graphql.scalar

While the performance issue here is likely somewhat fixeable,
TypeScript cannot be stopped from re-evaluating this.
Even if `getScalarTypeNames` is just replaced with all type names,
TypeScript struggles to compare a union that's this huge.

Instead, we now remove the constraint entirely.
@kitten kitten requested a review from JoviDeCroock February 3, 2024 11:12
Copy link

changeset-bot bot commented Feb 3, 2024

🦋 Changeset detected

Latest commit: 54e104d

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

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

@kitten kitten merged commit 4eff6ed into main Feb 3, 2024
3 checks passed
@kitten kitten deleted the fix/46-scalar-perf-issue branch February 3, 2024 11:32
@github-actions github-actions bot mentioned this pull request Feb 3, 2024
@kitten kitten added this to the Are We Fast Yet? milestone Mar 22, 2024
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.

Performance issue in getting enum with huge schema
2 participants