private Map<String, ObjectField> fieldMap(ObjectValue objectValue) { Map<String, ObjectField> result = new LinkedHashMap<>(); for (ObjectField objectField : objectValue.getObjectFields()) { result.put(objectField.getName(), objectField); } return result; }
@Override public ObjectValue deepCopy() { return new ObjectValue(deepCopy(objectFields), getSourceLocation(), getComments(), getIgnoredChars()); }
private static Value handleInputObject(Object _value, GraphQLInputObjectType type) { Map mapValue = objToMap(_value); List<GraphQLInputObjectField> fields = type.getFields(); List<ObjectField> fieldNodes = new ArrayList<>(); fields.forEach(field -> { GraphQLInputType fieldType = field.getType(); Value nodeValue = astFromValue(mapValue.get(field.getName()), fieldType); if (nodeValue != null) { fieldNodes.add(ObjectField.newObjectField().name(field.getName()).value(nodeValue).build()); } }); return ObjectValue.newObjectValue().objectFields(fieldNodes).build(); }
private Builder(ObjectValue existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.objectFields = existing.getObjectFields(); }
@Override public TraversalControl visitObjectValue(ObjectValue node, TraverserContext<Node> context) { ObjectValue changedNode = node.transform(builder -> { List<ObjectField> objectFields = sort(node.getObjectFields(), comparing(ObjectField::getName)); builder.objectFields(objectFields); }); return changeNode(context, changedNode); }
protected Predicate getArgumentPredicate(CriteriaBuilder cb, From<?,?> path, DataFetchingEnvironment environment, Argument argument) { ObjectValue whereValue = getValue(argument); if (whereValue.getChildren().isEmpty()) return cb.disjunction(); Logical logical = Optional.of(argument.getName()) .filter(it -> Arrays.asList("AND", "OR").contains(it)) .map(it -> Logical.valueOf(it)) .orElse(Logical.AND); List<Predicate> predicates = new ArrayList<>(); whereValue.getObjectFields().stream() .filter(it -> Arrays.asList("AND", "OR").contains(it.getName())) .map(it -> getArgumentPredicate(cb, path, new ArgumentEnvironment(environment, argument.getName()), new Argument(it.getName(), it.getValue()))) .forEach(predicates::add); whereValue.getObjectFields().stream() .filter(it -> !Arrays.asList("AND", "OR").contains(it.getName())) .map(it -> getFieldPredicate(it.getName(), cb, path, it, new ArgumentEnvironment(environment, argument.getName()), new Argument(it.getName(), it.getValue()))) .filter(predicate -> predicate != null) .forEach(predicates::add); if (predicates.isEmpty()) predicates.add(cb.disjunction()); return (logical == Logical.OR) ? cb.or(predicates.toArray(new Predicate[predicates.size()])) : cb.and(predicates.toArray(new Predicate[predicates.size()])); }
@Override public TraversalControl visitObjectValue(ObjectValue node, TraverserContext<Node> context) { return changeNode(context, node.transform(builder -> builder.objectFields(Collections.emptyList()))); }
public ObjectValue build() { ObjectValue objectValue = new ObjectValue(objectFields, sourceLocation, comments, ignoredChars); return objectValue; } }
private Builder(ObjectValue existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.objectFields = existing.getObjectFields(); }
@Override public TraversalControl visitObjectValue(ObjectValue node, TraverserContext<Node> context) { ObjectValue changedNode = node.transform(builder -> { List<ObjectField> objectFields = sort(node.getObjectFields(), comparing(ObjectField::getName)); builder.objectFields(objectFields); }); return changeNode(context, changedNode); }
private Predicate getFieldPredicate(String fieldName, CriteriaBuilder cb, From<?,?> path, ObjectField objectField, DataFetchingEnvironment environment, Argument argument) { ObjectValue expressionValue = (ObjectValue) objectField.getValue(); if(expressionValue.getChildren().isEmpty()) return cb.disjunction(); expressionValue.getObjectFields().stream() .filter(it -> Arrays.asList("AND","OR").contains(it.getName())) .map(it -> getFieldPredicate(fieldName, cb, path, it, expressionValue.getObjectFields().stream() .filter(it -> !Arrays.asList("AND","OR").contains(it.getName())) .map(it -> getPredicateFilter(new ObjectField(fieldName, it.getValue()),
@Override public ObjectValue withNewChildren(NodeChildrenContainer newChildren) { return transform(builder -> builder .objectFields(newChildren.getChildren(CHILD_OBJECT_FIELDS)) ); }
public ObjectValue build() { ObjectValue objectValue = new ObjectValue(objectFields, sourceLocation, comments, ignoredChars); return objectValue; } }
private Map<String, ObjectField> mapObjectValueFieldsByName(ObjectValue inputValue) { Map<String, ObjectField> inputValueFieldsByName = new LinkedHashMap<>(); for (ObjectField objectField : inputValue.getObjectFields()) { inputValueFieldsByName.put(objectField.getName(), objectField); } return inputValueFieldsByName; } }
@Override public ObjectValue deepCopy() { return new ObjectValue(deepCopy(objectFields), getSourceLocation(), getComments(), getIgnoredChars()); }
ObjectValue.Builder objectValue = ObjectValue.newObjectValue(); addCommonData(objectValue, ctx); List<ObjectField> objectFields = new ArrayList<>();
@Override public TraversalControl visitObjectValue(ObjectValue node, TraverserContext<Node> context) { return changeNode(context, node.transform(builder -> builder.objectFields(Collections.emptyList()))); }
List<ObjectField> fields = objectValue.getObjectFields(); List<InputValueDefinition> inputValueDefinitions = allowedTypeDefinition.getInputValueDefinitions();
ObjectValue.Builder objectValue = ObjectValue.newObjectValue(); addCommonData(objectValue, ctx); List<ObjectField> objectFields = new ArrayList<>();
@Override public ObjectValue withNewChildren(NodeChildrenContainer newChildren) { return transform(builder -> builder .objectFields(newChildren.getChildren(CHILD_OBJECT_FIELDS)) ); }