@@ -16,60 +16,9 @@ import kotlin.reflect.KParameter
16
16
import kotlin.reflect.full.findAnnotation
17
17
import com.expedia.graphql.annotations.GraphQLDirective as DirectiveAnnotation
18
18
19
- internal fun KAnnotatedElement.graphQLDescription (): String? {
20
- val directiveNames = listOfDirectives().map { it.normalizeDirectiveName() }
21
- val description = this .findAnnotation<GraphQLDescription >()?.value
22
- return formatGraphQLDescription(description, directiveNames)
23
- }
24
-
25
- internal fun Field.graphQLDescription (): String? {
26
- val directiveNames = listOfDirectives().map { it.normalizeDirectiveName() }
27
- val description = this .getAnnotation(GraphQLDescription ::class .java)?.value
28
- return formatGraphQLDescription(description, directiveNames)
29
- }
30
-
31
- private fun formatGraphQLDescription (description : String? , directiveNames : List <String >): String? = when {
32
- description != null && directiveNames.isNotEmpty() ->
33
- """ $description
34
- |
35
- |Directives: ${directiveNames.joinToString(" , " )}
36
- """ .trimMargin()
37
- description == null && directiveNames.isNotEmpty() ->
38
- " Directives: ${directiveNames.joinToString(" , " )} "
39
- else -> description
40
- }
41
-
42
- private fun KAnnotatedElement.listOfDirectives (): List <String > {
43
- val deprecationReason: String? = this .getDeprecationReason()?.let { " deprecated" }
44
-
45
- return this .annotations.asSequence()
46
- .mapNotNull { it.getDirectiveInfo() }
47
- .map {
48
- when {
49
- it.effectiveName.isNullOrEmpty().not () -> " @${it.effectiveName} "
50
- else -> null
51
- }
52
- }
53
- .plus(deprecationReason)
54
- .filterNotNull()
55
- .toList()
56
- }
57
-
58
- private fun Field.listOfDirectives (): List <String > {
59
- val deprecationReason: String? = this .getDeprecationReason()?.let { " deprecated" }
19
+ internal fun KAnnotatedElement.graphQLDescription (): String? = this .findAnnotation<GraphQLDescription >()?.value
60
20
61
- return this .declaredAnnotations.asSequence()
62
- .mapNotNull { it.getDirectiveInfo() }
63
- .map {
64
- when {
65
- it.effectiveName.isNullOrEmpty().not () -> " @${it.effectiveName} "
66
- else -> null
67
- }
68
- }
69
- .plus(deprecationReason)
70
- .filterNotNull()
71
- .toList()
72
- }
21
+ internal fun Field.graphQLDescription (): String? = this .getAnnotation(GraphQLDescription ::class .java)?.value
73
22
74
23
internal fun KAnnotatedElement.getDeprecationReason (): String? = this .findAnnotation<Deprecated >()?.getReason()
75
24
0 commit comments