Performance -- every field wrapped is unnecessarily wrapped in a promise
Opened this issue · 1 comments
Utsav2 commented
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.