-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3571 from graphql-java/add-field-fetching-method
Added field fetching method for Expedia
- Loading branch information
Showing
8 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
68 changes: 68 additions & 0 deletions
68
src/main/java/graphql/execution/instrumentation/FieldFetchingInstrumentationContext.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package graphql.execution.instrumentation; | ||
|
||
import graphql.Internal; | ||
import graphql.PublicSpi; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@PublicSpi | ||
public interface FieldFetchingInstrumentationContext extends InstrumentationContext<Object> { | ||
|
||
@Internal | ||
FieldFetchingInstrumentationContext NOOP = new FieldFetchingInstrumentationContext() { | ||
@Override | ||
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 | ||
* | ||
* @param nullableContext a {@link InstrumentationContext} that can be null | ||
* | ||
* @return a non null {@link InstrumentationContext} that maybe a no-op | ||
*/ | ||
@NotNull | ||
@Internal | ||
static FieldFetchingInstrumentationContext nonNullCtx(FieldFetchingInstrumentationContext nullableContext) { | ||
return nullableContext == null ? NOOP : nullableContext; | ||
} | ||
|
||
@Internal | ||
static FieldFetchingInstrumentationContext adapter(@Nullable InstrumentationContext<Object> context) { | ||
if (context == null) { | ||
return null; | ||
} | ||
return new FieldFetchingInstrumentationContext() { | ||
@Override | ||
public void onDispatched() { | ||
context.onDispatched(); | ||
} | ||
|
||
@Override | ||
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) { | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
9 changes: 9 additions & 0 deletions
9
...roovy/graphql/execution/instrumentation/TestingFieldFetchingInstrumentationContext.groovy
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package graphql.execution.instrumentation | ||
|
||
class TestingFieldFetchingInstrumentationContext extends TestingInstrumentContext<Map<String, Object>> implements FieldFetchingInstrumentationContext { | ||
|
||
TestingFieldFetchingInstrumentationContext(Object op, Object executionList, Object throwableList, Boolean useOnDispatch) { | ||
super(op, executionList, throwableList, useOnDispatch) | ||
} | ||
} | ||
|