-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Better javadoc on beginFieldFetching #3610
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,30 @@ | |
|
|
||
| import graphql.Internal; | ||
| import graphql.PublicSpi; | ||
| import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * FieldFetchingInstrumentationContext is returned back from the {@link Instrumentation#beginFieldFetching(InstrumentationFieldFetchParameters, InstrumentationState)} | ||
| * method, and it's much like the normal {@link InstrumentationContext} type except it also | ||
| * gives the value that was returned by a fields {@link graphql.schema.DataFetcher}. This allows | ||
| * you to know if the field value is a completely materialised field or if it's a {@link java.util.concurrent.CompletableFuture} | ||
| * promise to a value. | ||
| */ | ||
| @PublicSpi | ||
| public interface FieldFetchingInstrumentationContext extends InstrumentationContext<Object> { | ||
|
|
||
| /** | ||
| * This is called back with the value fetched for the field by its {@link graphql.schema.DataFetcher}. | ||
| * This can be a materialised java object or it maybe a {@link java.util.concurrent.CompletableFuture} | ||
| * promise to some async value that has not yet completed. | ||
| * | ||
| * @param fetchedValue a value that a field's {@link graphql.schema.DataFetcher} returned | ||
| */ | ||
| default void onFetchedValue(Object fetchedValue) { | ||
| } | ||
|
|
||
| @Internal | ||
| FieldFetchingInstrumentationContext NOOP = new FieldFetchingInstrumentationContext() { | ||
| @Override | ||
|
|
@@ -17,18 +35,13 @@ public void onDispatched() { | |
| @Override | ||
| public void onCompleted(Object result, Throwable t) { | ||
| } | ||
|
|
||
| @Override | ||
| public void onFetchedValue(Object fetchedValue) { | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * This creates a no-op {@link InstrumentationContext} if the one pass in is null | ||
| * This creates a no-op {@link InstrumentationContext} if the one passed in is null | ||
| * | ||
| * @param nullableContext a {@link InstrumentationContext} that can be null | ||
| * | ||
| * @return a non null {@link InstrumentationContext} that maybe a no-op | ||
| * @return a non-null {@link InstrumentationContext} that maybe a no-op | ||
| */ | ||
| @NotNull | ||
| @Internal | ||
|
|
@@ -51,18 +64,6 @@ public void onDispatched() { | |
| public void onCompleted(Object result, Throwable t) { | ||
| context.onCompleted(result, t); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFetchedValue(Object fetchedValue) { | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * This is called back with value fetched for the field. | ||
| * | ||
| * @param fetchedValue a value that a field's {@link graphql.schema.DataFetcher} returned | ||
| */ | ||
| default void onFetchedValue(Object fetchedValue) { | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a bit of field re-ordering |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 never needed because it is a default method on the interface