@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()) ; }
.arguments(argumentValues) .source(fetchedValue.getFetchedValue()) .localContext(fetchedValue.getLocalContext()) .nonNullFieldValidator(nonNullableFieldValidator) );
public FieldSubSelection createFieldSubSelection(ExecutionContext executionContext, FetchedValueAnalysis analysis) { ExecutionStepInfo executionInfo = analysis.getExecutionStepInfo(); MergedField field = analysis.getField(); Object source = analysis.getCompletedValue(); Object localContext = analysis.getFetchedValue().getLocalContext(); GraphQLOutputType sourceType = executionInfo.getUnwrappedNonNullType(); GraphQLObjectType resolvedObjectType = resolveType.resolveType(executionContext, field, source, executionInfo.getArguments(), sourceType); FieldCollectorParameters collectorParameters = newParameters() .schema(executionContext.getGraphQLSchema()) .objectType(resolvedObjectType) .fragments(executionContext.getFragmentsByName()) .variables(executionContext.getVariables()) .build(); MergedSelectionSet subFields = fieldCollector.collectFields(collectorParameters, executionInfo.getField()); // it is not really a new step but rather a refinement ExecutionStepInfo newExecutionStepInfoWithResolvedType = executionInfo.changeTypeWithPreservedNonNull(resolvedObjectType); return FieldSubSelection.newFieldSubSelection() .source(source) .localContext(localContext) .mergedSelectionSet(subFields) .executionInfo(newExecutionStepInfoWithResolvedType) .build(); }
@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()) ; }
.arguments(argumentValues) .source(fetchedValue.getFetchedValue()) .localContext(fetchedValue.getLocalContext()) .nonNullFieldValidator(nonNullableFieldValidator) );
public FieldSubSelection createFieldSubSelection(ExecutionContext executionContext, FetchedValueAnalysis analysis) { ExecutionStepInfo executionInfo = analysis.getExecutionStepInfo(); MergedField field = analysis.getField(); Object source = analysis.getCompletedValue(); Object localContext = analysis.getFetchedValue().getLocalContext(); GraphQLOutputType sourceType = executionInfo.getUnwrappedNonNullType(); GraphQLObjectType resolvedObjectType = resolveType.resolveType(executionContext, field, source, executionInfo.getArguments(), sourceType); FieldCollectorParameters collectorParameters = newParameters() .schema(executionContext.getGraphQLSchema()) .objectType(resolvedObjectType) .fragments(executionContext.getFragmentsByName()) .variables(executionContext.getVariables()) .build(); MergedSelectionSet subFields = fieldCollector.collectFields(collectorParameters, executionInfo.getField()); // it is not really a new step but rather a refinement ExecutionStepInfo newExecutionStepInfoWithResolvedType = executionInfo.changeTypeWithPreservedNonNull(resolvedObjectType); return FieldSubSelection.newFieldSubSelection() .source(source) .localContext(localContext) .mergedSelectionSet(subFields) .executionInfo(newExecutionStepInfoWithResolvedType) .build(); }