-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow for parse to return a Promise #4278
Conversation
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @JoviDeCroock, I'm @github-actions bot happy to help you with this PR 👋 Supported commandsPlease post this commands in separate comments and only one per comment:
|
d0349a4
to
368d5a1
Compare
): DocumentNode { | ||
const result = parse(source, options); | ||
/* c8 ignore next 3 */ | ||
if (isPromise(result)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we can't really test this I've opted to ignore the lines, it's more so that consumers will be prepared to handle a Promise
I do not feel comfortable changing the type signature of I've raised #4285 as a separate feature that I think has independent value (allowing for optional simple user-provided caches) that change the type signature because the return value may be async. |
This PR enables users to return a Promise from parsing, this is mainly intended so GraphQL servers are prepared for middleware approaches that can inject async caches.
I've opted to not do validate as this could create the impression that rules can run in the background, while all rules logic is synchronous.
I've also opted to not do the
parseValue
and other parse equivalents as these seem less relevant for the caching bit.😅 still have to fix a lot of types but first gauging the appeal of this.
Resolves #3421