public ExecutionPath getPath() { return dataFetchingEnvironment.getExecutionStepInfo().getPath(); }
fetchMap.put("path", executionStepInfo.getPath().toList()); fetchMap.put("parentType", executionStepInfo.getParent().getUnwrappedNonNullType().getName()); fetchMap.put("returnType", executionStepInfo.simplePrint());
public NonNullableFieldWasNullException(NonNullableFieldWasNullException previousException) { super( mkMessage( assertNotNull(previousException.executionStepInfo.getParent()), assertNotNull(previousException.executionStepInfo.getParent().getPath()) ), previousException ); this.executionStepInfo = previousException.executionStepInfo.getParent(); this.path = previousException.executionStepInfo.getParent().getPath(); }
return data("Not resolved : " + fetchedValueAnalysis.getExecutionStepInfo().getPath() + " with field " + fetchedValueAnalysis.getField(), emptyList());
public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters) { CallStack callStack = parameters.getInstrumentationState(); ExecutionPath path = parameters.getEnvironment().getExecutionStepInfo().getPath(); int level = path.getLevel(); return new InstrumentationContext<Object>() { @Override public void onDispatched(CompletableFuture result) { boolean dispatchNeeded; synchronized (callStack) { callStack.increaseFetchCount(level); dispatchNeeded = dispatchIfNeeded(callStack, level); } if (dispatchNeeded) { dispatch(); } } @Override public void onCompleted(Object result, Throwable t) { } }; }
public ExecutionStepInfo newExecutionStepInfoForListElement(ExecutionStepInfo executionInfo, int index) { GraphQLList fieldType = (GraphQLList) executionInfo.getUnwrappedNonNullType(); GraphQLOutputType typeInList = (GraphQLOutputType) fieldType.getWrappedType(); ExecutionPath indexedPath = executionInfo.getPath().segment(index); return executionInfo.transform(builder -> builder .parentInfo(executionInfo) .type(typeInList) .path(indexedPath)); }
private FetchedValueAnalysis handleUnresolvedTypeProblem(FetchedValue fetchedValue, ExecutionStepInfo executionInfo, UnresolvedTypeException e) { UnresolvedTypeError error = new UnresolvedTypeError(executionInfo.getPath(), executionInfo, e); return newFetchedValueAnalysis(OBJECT) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .nullValue() .error(error) .build(); }
private FetchedValueAnalysis analyzeList(ExecutionContext executionContext, FetchedValue fetchedValue, Object toAnalyze, ExecutionStepInfo executionInfo) { if (toAnalyze == null) { return newFetchedValueAnalysis(LIST) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .nullValue() .build(); } if (toAnalyze.getClass().isArray() || toAnalyze instanceof Iterable) { Collection<Object> collection = FpKit.toCollection(toAnalyze); return analyzeIterable(executionContext, fetchedValue, collection, executionInfo); } else { TypeMismatchError error = new TypeMismatchError(executionInfo.getPath(), executionInfo.getType()); return newFetchedValueAnalysis(LIST) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .nullValue() .error(error) .build(); } }
ExecutionId executionId = executionContext.getExecutionId(); try { log.debug("'{}' fetching field '{}' using data fetcher '{}'...", executionId, executionStepInfo.getPath(), dataFetcher.getClass().getName()); Object fetchedValueRaw = dataFetcher.get(environment); log.debug("'{}' field '{}' fetch returned '{}'", executionId, executionStepInfo.getPath(), fetchedValueRaw == null ? "null" : fetchedValueRaw.getClass().getName()); log.debug(String.format("'%s', field '%s' fetch threw exception", executionId, executionStepInfo.getPath()), e);
.fieldDefinition(currentParentExecutionStepInfo.getFieldDefinition()) .field(currentParentExecutionStepInfo.getField()) .path(currentParentExecutionStepInfo.getPath()) .parentInfo(currentParentExecutionStepInfo.getParent()) .build(); ExecutionPath fieldPath = curNode.getExecutionStepInfo().getPath().segment(mkNameForPath(currentField)); GraphQLFieldDefinition fieldDefinition = getFieldDef(executionContext.getGraphQLSchema(), curNode.getType(), currentField.getSingleField());
public CompletableFuture<FetchedValue> fetchValue(ExecutionContext executionContext, Object source, Object localContext, MergedField sameFields, ExecutionStepInfo executionInfo) { Field field = sameFields.getSingleField(); GraphQLFieldDefinition fieldDef = executionInfo.getFieldDefinition(); GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry(); GraphQLFieldsContainer parentType = getFieldsContainer(executionInfo); Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDef.getArguments(), field.getArguments(), executionContext.getVariables()); GraphQLOutputType fieldType = fieldDef.getType(); DataFetchingFieldSelectionSet fieldCollector = DataFetchingFieldSelectionSetImpl.newCollector(executionContext, fieldType, sameFields); DataFetchingEnvironment environment = newDataFetchingEnvironment(executionContext) .source(source) .localContext(localContext) .arguments(argumentValues) .fieldDefinition(fieldDef) .mergedField(sameFields) .fieldType(fieldType) .executionStepInfo(executionInfo) .parentType(parentType) .selectionSet(fieldCollector) .build(); ExecutionId executionId = executionContext.getExecutionId(); ExecutionPath path = executionInfo.getPath(); return callDataFetcher(codeRegistry, parentType, fieldDef, environment, executionId, path) .thenApply(rawFetchedValue -> FetchedValue.newFetchedValue() .fetchedValue(rawFetchedValue) .rawFetchedValue(rawFetchedValue) .build()) .exceptionally(exception -> handleExceptionWhileFetching(field, path, exception)) .thenApply(result -> unboxPossibleDataFetcherResult(sameFields, path, result, localContext)) .thenApply(this::unboxPossibleOptional); }
public ExecutionResultNode createResultNode(FetchedValueAnalysis fetchedValueAnalysis) { if (fetchedValueAnalysis.isNullValue() && fetchedValueAnalysis.getExecutionStepInfo().isNonNullType()) { NonNullableFieldWasNullException nonNullableFieldWasNullException = new NonNullableFieldWasNullException(fetchedValueAnalysis.getExecutionStepInfo(), fetchedValueAnalysis.getExecutionStepInfo().getPath()); return new LeafExecutionResultNode(fetchedValueAnalysis, nonNullableFieldWasNullException); } if (fetchedValueAnalysis.isNullValue()) { return new LeafExecutionResultNode(fetchedValueAnalysis, null); } if (fetchedValueAnalysis.getValueType() == FetchedValueAnalysis.FetchedValueType.OBJECT) { return createUnresolvedNode(fetchedValueAnalysis); } if (fetchedValueAnalysis.getValueType() == FetchedValueAnalysis.FetchedValueType.LIST) { return createListResultNode(fetchedValueAnalysis); } return new LeafExecutionResultNode(fetchedValueAnalysis, null); }
); log.debug("'{}' completing field '{}'...", executionContext.getExecutionId(), executionStepInfo.getPath());
public ExecutionStepInfo newExecutionStepInfoForSubField(ExecutionContext executionContext, MergedField mergedField, ExecutionStepInfo parentInfo) { GraphQLObjectType parentType = (GraphQLObjectType) parentInfo.getUnwrappedNonNullType(); GraphQLFieldDefinition fieldDefinition = Introspection.getFieldDef(executionContext.getGraphQLSchema(), parentType, mergedField.getName()); GraphQLOutputType fieldType = fieldDefinition.getType(); List<Argument> fieldArgs = mergedField.getArguments(); GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry(); Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), fieldArgs, executionContext.getVariables()); ExecutionPath newPath = parentInfo.getPath().segment(mergedField.getResultKey()); return parentInfo.transform(builder -> builder .parentInfo(parentInfo) .type(fieldType) .fieldDefinition(fieldDefinition) .fieldContainer(parentType) .field(mergedField) .path(newPath) .arguments(argumentValues)); }
serialized = serializeScalarValue(toAnalyze, scalarType); } catch (CoercingSerializeException e) { SerializationError error = new SerializationError(executionInfo.getPath(), e); return newFetchedValueAnalysis(SCALAR) .fetchedValue(fetchedValue)
private FetchedValueAnalysis analyzeEnumValue(FetchedValue fetchedValue, Object toAnalyze, GraphQLEnumType enumType, ExecutionStepInfo executionInfo) { if (toAnalyze == null) { return newFetchedValueAnalysis(SCALAR) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .nullValue() .build(); } Object serialized; try { serialized = enumType.getCoercing().serialize(toAnalyze); } catch (CoercingSerializeException e) { SerializationError error = new SerializationError(executionInfo.getPath(), e); return newFetchedValueAnalysis(SCALAR) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .nullValue() .error(error) .build(); } // handle non null values return newFetchedValueAnalysis(ENUM) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .completedValue(serialized) .build(); }
public NonNullableFieldWasNullException(NonNullableFieldWasNullException previousException) { super( mkMessage( assertNotNull(previousException.executionStepInfo.getParent()), assertNotNull(previousException.executionStepInfo.getParent().getPath()) ), previousException ); this.executionStepInfo = previousException.executionStepInfo.getParent(); this.path = previousException.executionStepInfo.getParent().getPath(); }
/** * This will set up the {@link GraphQLError#getLocations()} and {@link graphql.GraphQLError#getPath()} for you from the * fetching environment. * * @param dataFetchingEnvironment the data fetching environment * * @return a builder of {@link graphql.GraphQLError}s */ public static GraphqlErrorBuilder newError(DataFetchingEnvironment dataFetchingEnvironment) { return new GraphqlErrorBuilder() .location(dataFetchingEnvironment.getField().getSourceLocation()) .path(dataFetchingEnvironment.getExecutionStepInfo().getPath()); }
private FetchedValueAnalysis handleUnresolvedTypeProblem(FetchedValue fetchedValue, ExecutionStepInfo executionInfo, UnresolvedTypeException e) { UnresolvedTypeError error = new UnresolvedTypeError(executionInfo.getPath(), executionInfo, e); return newFetchedValueAnalysis(OBJECT) .fetchedValue(fetchedValue) .executionStepInfo(executionInfo) .nullValue() .error(error) .build(); }
public ExecutionStepInfo newExecutionStepInfoForListElement(ExecutionStepInfo executionInfo, int index) { GraphQLList fieldType = (GraphQLList) executionInfo.getUnwrappedNonNullType(); GraphQLOutputType typeInList = (GraphQLOutputType) fieldType.getWrappedType(); ExecutionPath indexedPath = executionInfo.getPath().segment(index); return executionInfo.transform(builder -> builder .parentInfo(executionInfo) .type(typeInList) .path(indexedPath)); }