/** * This will create an execution path from the list of objects * * @param objects the path objects * * @return a new execution path */ public static ExecutionPath fromList(List<?> objects) { assertNotNull(objects); ExecutionPath path = ExecutionPath.rootPath(); for (Object object : objects) { if (object instanceof Number) { path = path.segment(((Number) object).intValue()); } else { path = path.segment(String.valueOf(object)); } } return path; }
private ExecutionPath mkPath(QueryVisitorFieldEnvironment traversalEnv) { QueryVisitorFieldEnvironment parentEnvironment = traversalEnv.getParentEnvironment(); if (parentEnvironment == null) { return ExecutionPath.rootPath().segment(traversalEnv.getField().getName()); } else { Deque<QueryVisitorFieldEnvironment> stack = new ArrayDeque<>(); stack.push(traversalEnv); while (parentEnvironment != null) { stack.push(parentEnvironment); parentEnvironment = parentEnvironment.getParentEnvironment(); } ExecutionPath path = ExecutionPath.rootPath(); while (!stack.isEmpty()) { QueryVisitorFieldEnvironment environment = stack.pop(); path = path.segment(environment.getField().getName()); } return path; } }
/** * Parses an execution path from the provided path string in the format /segment1/segment2[index]/segmentN * * @param pathString the path string * * @return a parsed execution path */ public static ExecutionPath parse(String pathString) { pathString = pathString == null ? "" : pathString; pathString = pathString.trim(); StringTokenizer st = new StringTokenizer(pathString, "/[]", true); ExecutionPath path = ExecutionPath.rootPath(); while (st.hasMoreTokens()) { String token = st.nextToken(); if ("/".equals(token)) { assertTrue(st.hasMoreTokens(), mkErrMsg(), pathString); path = path.segment(st.nextToken()); } else if ("[".equals(token)) { assertTrue(st.countTokens() >= 2, mkErrMsg(), pathString); path = path.segment(Integer.parseInt(st.nextToken())); String closingBrace = st.nextToken(); assertTrue(closingBrace.equals("]"), mkErrMsg(), pathString); } else { throw new AssertException(format(mkErrMsg(), pathString)); } } return path; }
private ExecutionPath mkPath() { return ExecutionPath.rootPath().segment("heroes").segment(0).segment("abilities").segment("speed").segment(4); }
ExecutionPath path = ExecutionPath.rootPath(); ExecutionStepInfo executionStepInfo = newExecutionStepInfo().type(operationRootType).path(path).build(); NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo);
.build(); MergedSelectionSet mergedSelectionSet = fieldCollector.collectFields(collectorParameters, operationDefinition.getSelectionSet()); ExecutionStepInfo executionInfo = newExecutionStepInfo().type(operationRootType).path(ExecutionPath.rootPath()).build();
/** * This will create an execution path from the list of objects * * @param objects the path objects * * @return a new execution path */ public static ExecutionPath fromList(List<?> objects) { assertNotNull(objects); ExecutionPath path = ExecutionPath.rootPath(); for (Object object : objects) { if (object instanceof Number) { path = path.segment(((Number) object).intValue()); } else { path = path.segment(String.valueOf(object)); } } return path; }
private ExecutionPath mkPath(QueryVisitorFieldEnvironment traversalEnv) { QueryVisitorFieldEnvironment parentEnvironment = traversalEnv.getParentEnvironment(); if (parentEnvironment == null) { return ExecutionPath.rootPath().segment(traversalEnv.getField().getName()); } else { Deque<QueryVisitorFieldEnvironment> stack = new ArrayDeque<>(); stack.push(traversalEnv); while (parentEnvironment != null) { stack.push(parentEnvironment); parentEnvironment = parentEnvironment.getParentEnvironment(); } ExecutionPath path = ExecutionPath.rootPath(); while (!stack.isEmpty()) { QueryVisitorFieldEnvironment environment = stack.pop(); path = path.segment(environment.getField().getName()); } return path; } }
/** * Parses an execution path from the provided path string in the format /segment1/segment2[index]/segmentN * * @param pathString the path string * * @return a parsed execution path */ public static ExecutionPath parse(String pathString) { pathString = pathString == null ? "" : pathString; pathString = pathString.trim(); StringTokenizer st = new StringTokenizer(pathString, "/[]", true); ExecutionPath path = ExecutionPath.rootPath(); while (st.hasMoreTokens()) { String token = st.nextToken(); if ("/".equals(token)) { assertTrue(st.hasMoreTokens(), mkErrMsg(), pathString); path = path.segment(st.nextToken()); } else if ("[".equals(token)) { assertTrue(st.countTokens() >= 2, mkErrMsg(), pathString); path = path.segment(Integer.parseInt(st.nextToken())); String closingBrace = st.nextToken(); assertTrue(closingBrace.equals("]"), mkErrMsg(), pathString); } else { throw new AssertException(format(mkErrMsg(), pathString)); } } return path; }
ExecutionPath path = ExecutionPath.rootPath(); ExecutionStepInfo executionStepInfo = newExecutionStepInfo().type(operationRootType).path(path).build(); NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo);
.build(); MergedSelectionSet mergedSelectionSet = fieldCollector.collectFields(collectorParameters, operationDefinition.getSelectionSet()); ExecutionStepInfo executionInfo = newExecutionStepInfo().type(operationRootType).path(ExecutionPath.rootPath()).build();