@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()); }
static List<GraphQLError> validateFieldsAndArguments(FieldValidation fieldValidation, ExecutionContext executionContext) { Map<ExecutionPath, List<FieldAndArguments>> fieldArgumentsMap = new LinkedHashMap<>(); QueryTraversal queryTraversal = QueryTraversal.newQueryTraversal() .schema(executionContext.getGraphQLSchema()) .document(executionContext.getDocument()) .operationName(executionContext.getOperationDefinition().getName()) .variables(executionContext.getVariables()) .build(); queryTraversal.visitPreOrder(new QueryVisitorStub() { @Override public void visitField(QueryVisitorFieldEnvironment env) { Field field = env.getField(); if (field.getArguments() != null && !field.getArguments().isEmpty()) { // // only fields that have arguments make any sense to placed in play // since only they have variable input FieldAndArguments fieldArguments = new FieldAndArgumentsImpl(env); ExecutionPath path = fieldArguments.getPath(); List<FieldAndArguments> list = fieldArgumentsMap.getOrDefault(path, new ArrayList<>()); list.add(fieldArguments); fieldArgumentsMap.put(path, list); } } }); FieldValidationEnvironment environment = new FieldValidationEnvironmentImpl(executionContext, fieldArgumentsMap); // // this will allow a consumer to plugin their own validation of fields and arguments return fieldValidation.validateFields(environment); }
public static Builder newDataFetchingEnvironment(ExecutionContext executionContext) { return new Builder() .context(executionContext.getContext()) .root(executionContext.getRoot()) .graphQLSchema(executionContext.getGraphQLSchema()) .fragmentsByName(executionContext.getFragmentsByName()) .dataLoaderRegistry(executionContext.getDataLoaderRegistry()) .document(executionContext.getDocument()) .operationDefinition(executionContext.getOperationDefinition()) .variables(executionContext.getVariables()) .executionId(executionContext.getExecutionId()); }
@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()); }
static List<GraphQLError> validateFieldsAndArguments(FieldValidation fieldValidation, ExecutionContext executionContext) { Map<ExecutionPath, List<FieldAndArguments>> fieldArgumentsMap = new LinkedHashMap<>(); QueryTraversal queryTraversal = QueryTraversal.newQueryTraversal() .schema(executionContext.getGraphQLSchema()) .document(executionContext.getDocument()) .operationName(executionContext.getOperationDefinition().getName()) .variables(executionContext.getVariables()) .build(); queryTraversal.visitPreOrder(new QueryVisitorStub() { @Override public void visitField(QueryVisitorFieldEnvironment env) { Field field = env.getField(); if (field.getArguments() != null && !field.getArguments().isEmpty()) { // // only fields that have arguments make any sense to placed in play // since only they have variable input FieldAndArguments fieldArguments = new FieldAndArgumentsImpl(env); ExecutionPath path = fieldArguments.getPath(); List<FieldAndArguments> list = fieldArgumentsMap.getOrDefault(path, new ArrayList<>()); list.add(fieldArguments); fieldArgumentsMap.put(path, list); } } }); FieldValidationEnvironment environment = new FieldValidationEnvironmentImpl(executionContext, fieldArgumentsMap); // // this will allow a consumer to plugin their own validation of fields and arguments return fieldValidation.validateFields(environment); }
public static Builder newDataFetchingEnvironment(ExecutionContext executionContext) { return new Builder() .context(executionContext.getContext()) .root(executionContext.getRoot()) .graphQLSchema(executionContext.getGraphQLSchema()) .fragmentsByName(executionContext.getFragmentsByName()) .dataLoaderRegistry(executionContext.getDataLoaderRegistry()) .document(executionContext.getDocument()) .operationDefinition(executionContext.getOperationDefinition()) .variables(executionContext.getVariables()) .executionId(executionContext.getExecutionId()); }