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 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 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 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 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 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)); }