private MergedField(List<Field> fields) { assertNotEmpty(fields); this.fields = new ArrayList<>(fields); }
private CompletableFuture<NodeMultiZipper<ExecutionResultNode>> resolveNodes(ExecutionContext executionContext, List<NodeMultiZipper<ExecutionResultNode>> unresolvedNodes) { assertNotEmpty(unresolvedNodes, "unresolvedNodes can't be empty"); ExecutionResultNode commonRoot = unresolvedNodes.get(0).getCommonRoot(); CompletableFuture<List<List<NodeZipper<ExecutionResultNode>>>> listListCF = Async.flatMap(unresolvedNodes, executionResultMultiZipper -> fetchAndAnalyze(executionContext, executionResultMultiZipper.getZippers())); return flatList(listListCF).thenApply(zippers -> new NodeMultiZipper<ExecutionResultNode>(commonRoot, zippers, RESULT_NODE_ADAPTER)); }
private NodeZipper<T> moveUp(T parent, List<NodeZipper<T>> sameParent) { assertNotEmpty(sameParent, "expected at least one zipper"); Map<String, List<T>> childrenMap = nodeAdapter.getNamedChildren(parent); for (NodeZipper<T> zipper : sameParent) { NodeLocation location = zipper.getBreadcrumbs().get(0).getLocation(); childrenMap.computeIfAbsent(location.getName(), (key) -> new ArrayList<>()); List<T> childrenList = childrenMap.get(location.getName()); if (childrenList.size() > location.getIndex()) { childrenList.set(location.getIndex(), zipper.getCurNode()); } else { childrenList.add(zipper.getCurNode()); } } T newNode = nodeAdapter.withNewChildren(parent, childrenMap); List<Breadcrumb<T>> newBreadcrumbs = sameParent.get(0).getBreadcrumbs().subList(1, sameParent.get(0).getBreadcrumbs().size()); return new NodeZipper<>(newNode, newBreadcrumbs, this.nodeAdapter); }
/** * @param name the name * @param description the description * @param types the possible types * @param typeResolver the type resolver function * @param directives the directives on this type element * @param definition the AST definition * * @deprecated use the {@link #newUnionType()} builder pattern instead, as this constructor will be made private in a future version. */ @Internal @Deprecated public GraphQLUnionType(String name, String description, List<GraphQLOutputType> types, TypeResolver typeResolver, List<GraphQLDirective> directives, UnionTypeDefinition definition) { assertValidName(name); assertNotNull(types, "types can't be null"); assertNotEmpty(types, "A Union type must define one or more member types."); assertNotNull(directives, "directives cannot be null"); this.name = name; this.description = description; this.types = sortGraphQLTypes(types); this.typeResolver = typeResolver; this.definition = definition; this.directives = directives; }
private MergedField(List<Field> fields) { assertNotEmpty(fields); this.fields = new ArrayList<>(fields); }
private CompletableFuture<NodeMultiZipper<ExecutionResultNode>> resolveNodes(ExecutionContext executionContext, List<NodeMultiZipper<ExecutionResultNode>> unresolvedNodes) { assertNotEmpty(unresolvedNodes, "unresolvedNodes can't be empty"); ExecutionResultNode commonRoot = unresolvedNodes.get(0).getCommonRoot(); CompletableFuture<List<List<NodeZipper<ExecutionResultNode>>>> listListCF = Async.flatMap(unresolvedNodes, executionResultMultiZipper -> fetchAndAnalyze(executionContext, executionResultMultiZipper.getZippers())); return flatList(listListCF).thenApply(zippers -> new NodeMultiZipper<ExecutionResultNode>(commonRoot, zippers, RESULT_NODE_ADAPTER)); }
private NodeZipper<T> moveUp(T parent, List<NodeZipper<T>> sameParent) { assertNotEmpty(sameParent, "expected at least one zipper"); Map<String, List<T>> childrenMap = nodeAdapter.getNamedChildren(parent); for (NodeZipper<T> zipper : sameParent) { NodeLocation location = zipper.getBreadcrumbs().get(0).getLocation(); childrenMap.computeIfAbsent(location.getName(), (key) -> new ArrayList<>()); List<T> childrenList = childrenMap.get(location.getName()); if (childrenList.size() > location.getIndex()) { childrenList.set(location.getIndex(), zipper.getCurNode()); } else { childrenList.add(zipper.getCurNode()); } } T newNode = nodeAdapter.withNewChildren(parent, childrenMap); List<Breadcrumb<T>> newBreadcrumbs = sameParent.get(0).getBreadcrumbs().subList(1, sameParent.get(0).getBreadcrumbs().size()); return new NodeZipper<>(newNode, newBreadcrumbs, this.nodeAdapter); }
/** * @param name the name * @param description the description * @param types the possible types * @param typeResolver the type resolver function * @param directives the directives on this type element * @param definition the AST definition * * @deprecated use the {@link #newUnionType()} builder pattern instead, as this constructor will be made private in a future version. */ @Internal @Deprecated public GraphQLUnionType(String name, String description, List<GraphQLOutputType> types, TypeResolver typeResolver, List<GraphQLDirective> directives, UnionTypeDefinition definition) { assertValidName(name); assertNotNull(types, "types can't be null"); assertNotEmpty(types, "A Union type must define one or more member types."); assertNotNull(directives, "directives cannot be null"); this.name = name; this.description = description; this.types = sortGraphQLTypes(types); this.typeResolver = typeResolver; this.definition = definition; this.directives = directives; }