private boolean isDataLoaderCompatibleExecution(ExecutionContext executionContext) { // // currently we only support Query operations and ONLY with AsyncExecutionStrategy as the query ES // This may change in the future but this is the fix for now // if (executionContext.getOperationDefinition().getOperation() == OperationDefinition.Operation.QUERY) { ExecutionStrategy queryStrategy = executionContext.getQueryStrategy(); if (queryStrategy instanceof AsyncExecutionStrategy) { return true; } } return false; }
@Internal ExecutionContextBuilder(ExecutionContext other) { instrumentation = other.getInstrumentation(); executionId = other.getExecutionId(); instrumentationState = other.getInstrumentationState(); graphQLSchema = other.getGraphQLSchema(); queryStrategy = other.getQueryStrategy(); mutationStrategy = other.getMutationStrategy(); subscriptionStrategy = other.getSubscriptionStrategy(); context = other.getContext(); root = other.getRoot(); document = other.getDocument(); operationDefinition = other.getOperationDefinition(); variables = new HashMap<>(other.getVariables()); fragmentsByName = new HashMap<>(other.getFragmentsByName()); dataLoaderRegistry = other.getDataLoaderRegistry(); errors = new ArrayList<>(other.getErrors()); }
/** * Called to turn an java object value into an graphql object value * * @param executionContext contains the top level execution parameters * @param parameters contains the parameters holding the fields to be executed and source object * @param resolvedObjectType the resolved object type * @param result the result to be coerced * * @return a promise to an {@link ExecutionResult} */ protected CompletableFuture<ExecutionResult> completeValueForObject(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLObjectType resolvedObjectType, Object result) { ExecutionStepInfo executionStepInfo = parameters.getExecutionStepInfo(); FieldCollectorParameters collectorParameters = newParameters() .schema(executionContext.getGraphQLSchema()) .objectType(resolvedObjectType) .fragments(executionContext.getFragmentsByName()) .variables(executionContext.getVariables()) .build(); MergedSelectionSet subFields = fieldCollector.collectFields(collectorParameters, parameters.getField()); ExecutionStepInfo newExecutionStepInfo = executionStepInfo.changeTypeWithPreservedNonNull(resolvedObjectType); NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, newExecutionStepInfo); ExecutionStrategyParameters newParameters = parameters.transform(builder -> builder.executionStepInfo(newExecutionStepInfo) .fields(subFields) .nonNullFieldValidator(nonNullableFieldValidator) .source(result) ); // Calling this from the executionContext to ensure we shift back from mutation strategy to the query strategy. return executionContext.getQueryStrategy().execute(executionContext, newParameters); }
private boolean isDataLoaderCompatibleExecution(ExecutionContext executionContext) { // // currently we only support Query operations and ONLY with AsyncExecutionStrategy as the query ES // This may change in the future but this is the fix for now // if (executionContext.getOperationDefinition().getOperation() == OperationDefinition.Operation.QUERY) { ExecutionStrategy queryStrategy = executionContext.getQueryStrategy(); if (queryStrategy instanceof AsyncExecutionStrategy) { return true; } } return false; }
@Internal ExecutionContextBuilder(ExecutionContext other) { instrumentation = other.getInstrumentation(); executionId = other.getExecutionId(); instrumentationState = other.getInstrumentationState(); graphQLSchema = other.getGraphQLSchema(); queryStrategy = other.getQueryStrategy(); mutationStrategy = other.getMutationStrategy(); subscriptionStrategy = other.getSubscriptionStrategy(); context = other.getContext(); root = other.getRoot(); document = other.getDocument(); operationDefinition = other.getOperationDefinition(); variables = new HashMap<>(other.getVariables()); fragmentsByName = new HashMap<>(other.getFragmentsByName()); dataLoaderRegistry = other.getDataLoaderRegistry(); errors = new ArrayList<>(other.getErrors()); }
public ReactiveContext(ExecutionContext context, Object key) { super( context.getInstrumentation(), context.getExecutionId(), context.getGraphQLSchema(), context.getQueryStrategy(), context.getMutationStrategy(), context.getSubscriptionStrategy(), context.getFragmentsByName(), context.getOperationDefinition(), context.getVariables(), context.getRoot() ); this.key = key; this.parent = context; }
/** * Called to turn an java object value into an graphql object value * * @param executionContext contains the top level execution parameters * @param parameters contains the parameters holding the fields to be executed and source object * @param resolvedObjectType the resolved object type * @param result the result to be coerced * * @return a promise to an {@link ExecutionResult} */ protected CompletableFuture<ExecutionResult> completeValueForObject(ExecutionContext executionContext, ExecutionStrategyParameters parameters, GraphQLObjectType resolvedObjectType, Object result) { ExecutionStepInfo executionStepInfo = parameters.getExecutionStepInfo(); FieldCollectorParameters collectorParameters = newParameters() .schema(executionContext.getGraphQLSchema()) .objectType(resolvedObjectType) .fragments(executionContext.getFragmentsByName()) .variables(executionContext.getVariables()) .build(); MergedSelectionSet subFields = fieldCollector.collectFields(collectorParameters, parameters.getField()); ExecutionStepInfo newExecutionStepInfo = executionStepInfo.changeTypeWithPreservedNonNull(resolvedObjectType); NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, newExecutionStepInfo); ExecutionStrategyParameters newParameters = parameters.transform(builder -> builder.executionStepInfo(newExecutionStepInfo) .fields(subFields) .nonNullFieldValidator(nonNullableFieldValidator) .source(result) ); // Calling this from the executionContext to ensure we shift back from mutation strategy to the query strategy. return executionContext.getQueryStrategy().execute(executionContext, newParameters); }