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

Performance -- every field wrapped is unnecessarily wrapped in a promise #1522

Open
Utsav2 opened this issue Sep 25, 2023 · 1 comment
Open

Comments

@Utsav2
Copy link

Utsav2 commented Sep 25, 2023

Bug report

Every rule evaluation assumes that the return value from the evaluation function is a promise.

Describe the bug

This implicitly converts every response value into a promise. For large, nested responses, this causes lots of promises to be created and immediately resolved, which slows down the event loop and response times per request significantly. I've noticed over a million promises being invoked and resolved in our production environment.

I believe this is the root cause for most of the other performance issues being flagged in this repository.

Expected behavior

GraphQL Shield should only await functions that actually return promises. A lot of other libraries, like apollo-server, await on promises only if the return value is actually a promise.

@OdedNir
Copy link

OdedNir commented Mar 31, 2024

@Utsav2 I'm also experiencing the same thing.

When using applyMiddleware each default field is unnecessary running the rule applied for the type.
Is there an option to choose if it will run once only for the type?

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

2 participants