public MergedField build() { return new MergedField(fields); }
@Override public List<Field> getFields() { return mergedField.getFields(); }
private SelectedFieldImpl(String qualifiedName, MergedField parentFields, GraphQLFieldDefinition fieldDefinition, Map<String, Object> arguments) { this.qualifiedName = qualifiedName; this.name = parentFields.getName(); this.fieldDefinition = fieldDefinition; this.arguments = arguments; GraphQLType unwrappedType = GraphQLTypeUtil.unwrapAll(fieldDefinition.getType()); if (unwrappedType instanceof GraphQLFieldsContainer) { this.selectionSet = new DataFetchingFieldSelectionSetImpl(parentFields, (GraphQLFieldsContainer) unwrappedType, graphQLSchema, variables, fragmentsByName); } else { this.selectionSet = NOOP; } }
private void collectField(FieldCollectorParameters parameters, Map<String, MergedField> fields, Field field) { if (!conditionalNodes.shouldInclude(parameters.getVariables(), field.getDirectives())) { return; } String name = getFieldEntryKey(field); if (fields.containsKey(name)) { MergedField curFields = fields.get(name); fields.put(name, curFields.transform(builder -> builder.addField(field))); } else { fields.put(name, MergedField.newMergedField(field).build()); } }
@Override public Field getField() { return mergedField.getSingleField(); }
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)); }
MergedField field = parameters.getField(); GraphQLObjectType parentType = (GraphQLObjectType) parameters.getExecutionStepInfo().getUnwrappedNonNullType(); GraphQLFieldDefinition fieldDef = getFieldDef(executionContext.getGraphQLSchema(), parentType, field.getSingleField()); Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDef.getArguments(), field.getArguments(), executionContext.getVariables());
private List<CompletableFuture<NamedResultNode>> fetchedValueAnalysisToNodesAsync(List<CompletableFuture<FetchedValueAnalysis>> list) { return Async.map(list, fetchedValueAnalysis -> { ExecutionResultNode resultNode = resultNodesCreator.createResultNode(fetchedValueAnalysis); return new NamedResultNode(fetchedValueAnalysis.getField().getResultKey(), resultNode); }); }
/** * Builds the type info hierarchy for the current field * * @param executionContext the execution context in play * @param parameters contains the parameters holding the fields to be executed and source object * @param fieldDefinition the field definition to build type info for * * @return a new type info */ protected ExecutionStepInfo createExecutionStepInfo(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLFieldDefinition fieldDefinition, GraphQLObjectType fieldContainer) { GraphQLOutputType fieldType = fieldDefinition.getType(); List<Argument> fieldArgs = parameters.getField().getArguments(); GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry(); Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), fieldArgs, executionContext.getVariables()); return newExecutionStepInfo() .type(fieldType) .fieldDefinition(fieldDefinition) .fieldContainer(fieldContainer) .field(parameters.getField()) .path(parameters.getPath()) .parentInfo(parameters.getExecutionStepInfo()) .arguments(argumentValues) .build(); }
/** * All merged fields share the same arguments. * * @return the list of arguments */ public List<Argument> getArguments() { return getSingleField().getArguments(); }
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)); }
private void collectField(FieldCollectorParameters parameters, Map<String, MergedField> fields, Field field) { if (!conditionalNodes.shouldInclude(parameters.getVariables(), field.getDirectives())) { return; } String name = getFieldEntryKey(field); if (fields.containsKey(name)) { MergedField curFields = fields.get(name); fields.put(name, curFields.transform(builder -> builder.addField(field))); } else { fields.put(name, MergedField.newMergedField(field).build()); } }
MergedField field = parameters.getField(); GraphQLObjectType parentType = (GraphQLObjectType) parameters.getExecutionStepInfo().getUnwrappedNonNullType(); GraphQLFieldDefinition fieldDef = getFieldDef(executionContext.getGraphQLSchema(), parentType, field.getSingleField()); Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDef.getArguments(), field.getArguments(), executionContext.getVariables());
public List<NamedResultNode> fetchedValueAnalysisToNodes(List<FetchedValueAnalysis> fetchedValueAnalysisList) { return FpKit.map(fetchedValueAnalysisList, fetchedValueAnalysis -> { ExecutionResultNode resultNode = resultNodesCreator.createResultNode(fetchedValueAnalysis); return new NamedResultNode(fetchedValueAnalysis.getField().getResultKey(), resultNode); }); }
/** * Builds the type info hierarchy for the current field * * @param executionContext the execution context in play * @param parameters contains the parameters holding the fields to be executed and source object * @param fieldDefinition the field definition to build type info for * @param fieldContainer the field container * * @return a new type info */ protected ExecutionStepInfo createExecutionStepInfo(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLFieldDefinition fieldDefinition, GraphQLObjectType fieldContainer) { GraphQLOutputType fieldType = fieldDefinition.getType(); List<Argument> fieldArgs = parameters.getField().getArguments(); GraphQLCodeRegistry codeRegistry = executionContext.getGraphQLSchema().getCodeRegistry(); Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), fieldArgs, executionContext.getVariables()); return newExecutionStepInfo() .type(fieldType) .fieldDefinition(fieldDefinition) .fieldContainer(fieldContainer) .field(parameters.getField()) .path(parameters.getPath()) .parentInfo(parameters.getExecutionStepInfo()) .arguments(argumentValues) .build(); }
public SourceLocation getSourceLocation() { return getField().getSingleField().getSourceLocation(); }
private Builder(MergedField existing) { this.fields = existing.getFields(); }
private boolean isDeferred(ExecutionContext executionContext, ExecutionStrategyParameters parameters, MergedField currentField) { DeferSupport deferSupport = executionContext.getDeferSupport(); if (deferSupport.checkForDeferDirective(currentField)) { DeferredErrorSupport errorSupport = new DeferredErrorSupport(); // with a deferred field we are really resetting where we execute from, that is from this current field onwards Map<String, MergedField> fields = new LinkedHashMap<>(); fields.put(currentField.getName(), currentField); ExecutionStrategyParameters callParameters = parameters.transform(builder -> { MergedSelectionSet mergedSelectionSet = newMergedSelectionSet().subFields(fields).build(); builder.deferredErrorSupport(errorSupport) .field(currentField) .fields(mergedSelectionSet) .parent(null) // this is a break in the parent -> child chain - its a new start effectively .listSize(0) .currentListIndex(0); } ); DeferredCall call = new DeferredCall(deferredExecutionResult(executionContext, callParameters), errorSupport); deferSupport.enqueue(call); return true; } return false; }
public List<NamedResultNode> fetchedValueAnalysisToNodes(List<FetchedValueAnalysis> fetchedValueAnalysisList) { return FpKit.map(fetchedValueAnalysisList, fetchedValueAnalysis -> { ExecutionResultNode resultNode = resultNodesCreator.createResultNode(fetchedValueAnalysis); return new NamedResultNode(fetchedValueAnalysis.getField().getResultKey(), resultNode); }); }
public MergedField build() { return new MergedField(fields); }