-
Notifications
You must be signed in to change notification settings - Fork 1.2k
change preparsedDocumentProvider return value to CompletableFuture<PreparsedDocumentEntry> #2612
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
Conversation
…to CompletableFuture<PreparsedDocumentEntry>
| * @throws graphql.execution.preparsed.persisted.PersistedQueryNotFound if the query id is not know at all and you have no query text | ||
| */ | ||
| PreparsedDocumentEntry getPersistedQueryDocument(Object persistedQueryId, ExecutionInput executionInput, PersistedQueryCacheMiss onCacheMiss) throws PersistedQueryNotFound; | ||
| CompletableFuture<PreparsedDocumentEntry> getPersistedQueryDocument(Object persistedQueryId, ExecutionInput executionInput, PersistedQueryCacheMiss onCacheMiss) throws PersistedQueryNotFound; |
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.
This is indeed a great idea. This should indeed be an async method because its likely to go to a DB etc...for most implementations.
However as implemented this is a hard breaking change.
We can avoid this in this case.
We can
- deprecate the
PreparsedDocumentEntry getPersistedQueryDocument(method - put in a
default CompletableFuture<PreparsedDocumentEntry> getPersistedQueryDocumentAsync(method - make the default call the
getPersistedQueryDocumentand wrap it in a completed CF - make all the calls sites called
CompletableFuture<PreparsedDocumentEntry> getPersistedQueryDocumentAsync(and hence it will invoke the sync version for every one else.
bbakerman
left a comment
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.
We need to make this a non breaking API change because we can. We sometimes make breaking changes when we cant avoid them but in this case we can and we should avoid it.
Otherwise thank you very much for this PR
| } | ||
|
|
||
| @Override | ||
| public PreparsedDocumentEntry getDocument(ExecutionInput executionInput, Function<ExecutionInput, PreparsedDocumentEntry> parseAndValidateFunction) { |
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.
Same pattern here. We delegate back from an async method to this method
This is also @PublicSpi and hence people will have derived from it and hence we dont want to break them
|
@bbakerman thanks for your review i understand your comment and i fixed this PR If you have time, please review again. |
src/main/java/graphql/execution/preparsed/PreparsedDocumentProvider.java
Show resolved
Hide resolved
src/main/java/graphql/execution/preparsed/persisted/PersistedQueryCache.java
Show resolved
Hide resolved
| def getDoc = inMemCache.getPersistedQueryDocument(hash, ei, onMiss) | ||
| def doc = getDoc.document | ||
| def getDoc = inMemCache.getPersistedQueryDocumentAsync(hash, ei, onMiss) | ||
| def doc = getDoc.get().document |
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.
Can we have one test that goes via the old deprecated path so that we have surety that while its alive it works
|
@bbakerman thanks for review add javaDoc, |
bbakerman
left a comment
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.
I am happy to merge this once the explicit imports is fixed.
Sorry to be a pain.
This is a great PR and will be very useful and I am keen to get it in - but I want to maintain code health as well
src/main/java/graphql/GraphQL.java
Outdated
| import graphql.execution.instrumentation.InstrumentationState; | ||
| import graphql.execution.instrumentation.SimpleInstrumentation; | ||
| import graphql.execution.*; | ||
| import graphql.execution.instrumentation.*; |
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.
Sorry we require explicit imports - if you are using IDEA set them to 999 before using * for this project
| import graphql.Internal; | ||
| import graphql.ParseAndValidate; | ||
| import graphql.ParseAndValidateResult; | ||
| import graphql.*; |
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.
explicit imports
|
@bbakerman Thanks for the review I'm glad it could be a merge |
bbakerman
left a comment
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.
Thanks you and thanks for the follow up
|
Build failing |
|
@bbakerman |
|
Hmmm not sure why this is failing the tests |
|
@bbakerman hi
I think, should add an exception handling layer |
bbakerman
left a comment
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.
Thanks so much for this PR
change pre parsed Document Provider return value to
CompletableFuture<Preparsed DocumentEntry>because
we use graphql-java on Spring webflux
if we use mongodb or redis for persistent query db then
preparsedDocumentProvider.getDocument()call is blocking