protected Observable<Double> calculateFieldComplexity(ExecutionContext executionContext, GraphQLObjectType parentType, List<Field> fields, Observable<Double> childScore) {
return childScore.flatMap(aDouble -> {
Observable<Double> result = Observable.just(aDouble + NODE_SCORE);
GraphQLFieldDefinition fieldDef = getFieldDef(executionContext.getGraphQLSchema(), parentType, fields.get(0));
if (fieldDef != null) {
GraphQLFieldDefinitionWrapper graphQLFieldDefinitionWrapper = getGraphQLFieldDefinitionWrapper(fieldDef);
if (graphQLFieldDefinitionWrapper != null) {
Expression expression = graphQLFieldDefinitionWrapper.getComplexitySpelExpression();
if (expression != null) {
Map<String, Object> argumentValues = valuesResolver.getArgumentValues(fieldDef.getArguments(), fields.get(0).getArguments(), executionContext.getVariables());
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable(GraphQLConstants.EXECUTION_COMPLEXITY_CHILD_SCORE, aDouble);
if (argumentValues != null)
context.setVariables(argumentValues);
result = Observable.just(expression.getValue(context, Double.class));
}
}
}
return addComplexityCheckObservable(executionContext, result);
});
}