public FetchedValueAnalysis analyzeFetchedValue(ExecutionContext executionContext, FetchedValue fetchedValue, ExecutionStepInfo executionInfo) throws NonNullableFieldWasNullException { return analyzeFetchedValueImpl(executionContext, fetchedValue, fetchedValue.getFetchedValue(), executionInfo); }
private CompletableFuture<Publisher<Object>> createSourceEventStream(ExecutionContext executionContext, ExecutionStrategyParameters parameters) { ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters); CompletableFuture<FetchedValue> fieldFetched = fetchField(executionContext, newParameters); return fieldFetched.thenApply(fetchedValue -> { Object publisher = fetchedValue.getFetchedValue(); if (publisher != null) { assertTrue(publisher instanceof Publisher, "You data fetcher must return a Publisher of events when using graphql subscriptions"); } //noinspection unchecked return (Publisher<Object>) publisher; }); }
private FetchedValue unboxPossibleOptional(FetchedValue result) { return result.transform( builder -> builder.fetchedValue(UnboxPossibleOptional.unboxPossibleOptional(result.getFetchedValue())) ); }
private FetchedValue unboxPossibleDataFetcherResult(MergedField sameField, ExecutionPath executionPath, FetchedValue result, Object localContext) { if (result.getFetchedValue() instanceof DataFetcherResult) { DataFetcherResult<?> dataFetcherResult = (DataFetcherResult) result.getFetchedValue(); List<AbsoluteGraphQLError> addErrors = dataFetcherResult.getErrors().stream() .map(relError -> new AbsoluteGraphQLError(sameField, executionPath, relError)) .collect(Collectors.toList()); List<GraphQLError> newErrors = new ArrayList<>(result.getErrors()); newErrors.addAll(addErrors); Object newLocalContext = dataFetcherResult.getLocalContext(); if (newLocalContext == null) { // if the field returns nothing then they get the context of their parent field newLocalContext = localContext; } return FetchedValue.newFetchedValue() .fetchedValue(dataFetcherResult.getData()) .rawFetchedValue(result.getRawFetchedValue()) .errors(newErrors) .localContext(newLocalContext) .build(); } else { return result; } } }
@SuppressWarnings("unchecked") private List<FetchedValue> extractBatchedValues(FetchedValue fetchedValueContainingList, int expectedSize) { List<Object> list = (List<Object>) fetchedValueContainingList.getFetchedValue(); Assert.assertTrue(list.size() == expectedSize, "Unexpected result size"); List<FetchedValue> result = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { List<GraphQLError> errors; if (i == 0) { errors = fetchedValueContainingList.getErrors(); } else { errors = Collections.emptyList(); } FetchedValue fetchedValue = FetchedValue.newFetchedValue() .fetchedValue(list.get(i)) .rawFetchedValue(fetchedValueContainingList.getRawFetchedValue()) .errors(errors) .localContext(fetchedValueContainingList.getLocalContext()) .build(); result.add(fetchedValue); } return result; }
public static Builder newFetchedValue(FetchedValue otherValue) { return new Builder() .fetchedValue(otherValue.getFetchedValue()) .rawFetchedValue(otherValue.getRawFetchedValue()) .errors(otherValue.getErrors()) .localContext(otherValue.getLocalContext()) ; }
builder.executionStepInfo(executionStepInfo) .arguments(argumentValues) .source(fetchedValue.getFetchedValue()) .localContext(fetchedValue.getLocalContext()) .nonNullFieldValidator(nonNullableFieldValidator)
public FetchedValueAnalysis analyzeFetchedValue(ExecutionContext executionContext, FetchedValue fetchedValue, ExecutionStepInfo executionInfo) throws NonNullableFieldWasNullException { return analyzeFetchedValueImpl(executionContext, fetchedValue, fetchedValue.getFetchedValue(), executionInfo); }
private CompletableFuture<Publisher<Object>> createSourceEventStream(ExecutionContext executionContext, ExecutionStrategyParameters parameters) { ExecutionStrategyParameters newParameters = firstFieldOfSubscriptionSelection(parameters); CompletableFuture<FetchedValue> fieldFetched = fetchField(executionContext, newParameters); return fieldFetched.thenApply(fetchedValue -> { Object publisher = fetchedValue.getFetchedValue(); if (publisher != null) { assertTrue(publisher instanceof Publisher, "You data fetcher must return a Publisher of events when using graphql subscriptions"); } //noinspection unchecked return (Publisher<Object>) publisher; }); }
private FetchedValue unboxPossibleOptional(FetchedValue result) { return result.transform( builder -> builder.fetchedValue(UnboxPossibleOptional.unboxPossibleOptional(result.getFetchedValue())) ); }
@SuppressWarnings("unchecked") private List<FetchedValue> extractBatchedValues(FetchedValue fetchedValueContainingList, int expectedSize) { List<Object> list = (List<Object>) fetchedValueContainingList.getFetchedValue(); Assert.assertTrue(list.size() == expectedSize, "Unexpected result size"); List<FetchedValue> result = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { List<GraphQLError> errors; if (i == 0) { errors = fetchedValueContainingList.getErrors(); } else { errors = Collections.emptyList(); } FetchedValue fetchedValue = FetchedValue.newFetchedValue() .fetchedValue(list.get(i)) .rawFetchedValue(fetchedValueContainingList.getRawFetchedValue()) .errors(errors) .localContext(fetchedValueContainingList.getLocalContext()) .build(); result.add(fetchedValue); } return result; }
private FetchedValue unboxPossibleDataFetcherResult(MergedField sameField, ExecutionPath executionPath, FetchedValue result, Object localContext) { if (result.getFetchedValue() instanceof DataFetcherResult) { DataFetcherResult<?> dataFetcherResult = (DataFetcherResult) result.getFetchedValue(); if (dataFetcherResult.isMapRelativeErrors()) { addErrors = dataFetcherResult.getErrors().stream()
public static Builder newFetchedValue(FetchedValue otherValue) { return new Builder() .fetchedValue(otherValue.getFetchedValue()) .rawFetchedValue(otherValue.getRawFetchedValue()) .errors(otherValue.getErrors()) .localContext(otherValue.getLocalContext()) ; }
builder.executionStepInfo(executionStepInfo) .arguments(argumentValues) .source(fetchedValue.getFetchedValue()) .localContext(fetchedValue.getLocalContext()) .nonNullFieldValidator(nonNullableFieldValidator)