fun applyDirectivesKotlin()

in graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/shared/DirectivesUtils.kt [39:57]


fun applyDirectivesKotlin(
    directives: List<Directive>,
    config: CodeGenConfig,
): MutableList<AnnotationSpec> =
    directives.fold(mutableListOf()) { annotations, directive ->
        val argumentMap = createArgumentMap(directive)
        if (directive.name == ParserConstants.CUSTOM_ANNOTATION && config.generateCustomAnnotations) {
            annotations.add(customAnnotation(argumentMap, config))
        }
        if (directive.name == ParserConstants.DEPRECATED && config.addDeprecatedAnnotation) {
            if (argumentMap.containsKey(ParserConstants.REASON)) {
                annotations.add(deprecatedAnnotation((argumentMap[ParserConstants.REASON] as StringValue).value))
            } else {
                annotations.add(deprecatedAnnotation(ParserConstants.DEPRECATED_IN_THE_GRAPHQL_SCHEMA))
            }
        }

        annotations
    }