Skip to content

Commit ac53276

Browse files
authored
refactor!: split up __Described interface (#547)
Splits up the `__Described` interface into `Describable` for the description part, and `Named` for the name part. Also removes the `__` prefix because those are marker interfaces and not introspection types. BREAKING CHANGE: `__Described` interface no longer exists, and is replaced by `Describable` and `Named`.
1 parent f8bd093 commit ac53276

File tree

9 files changed

+29
-25
lines changed

9 files changed

+29
-25
lines changed

kgraphql/api/kgraphql.api

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,14 @@ public final class com/apurebase/kgraphql/schema/execution/TypeCondition {
901901
public final fun getOnType ()Lcom/apurebase/kgraphql/schema/structure/Type;
902902
}
903903

904+
public abstract interface class com/apurebase/kgraphql/schema/introspection/Describable {
905+
public abstract fun getDescription ()Ljava/lang/String;
906+
}
907+
908+
public abstract interface class com/apurebase/kgraphql/schema/introspection/Named {
909+
public abstract fun getName ()Ljava/lang/String;
910+
}
911+
904912
public abstract interface annotation class com/apurebase/kgraphql/schema/introspection/NotIntrospected : java/lang/annotation/Annotation {
905913
}
906914

@@ -936,26 +944,21 @@ public final class com/apurebase/kgraphql/schema/introspection/TypeKind : java/l
936944
public static fun values ()[Lcom/apurebase/kgraphql/schema/introspection/TypeKind;
937945
}
938946

939-
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Described {
940-
public abstract fun getDescription ()Ljava/lang/String;
941-
public abstract fun getName ()Ljava/lang/String;
942-
}
943-
944-
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Directive : com/apurebase/kgraphql/schema/introspection/__Described {
947+
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Directive : com/apurebase/kgraphql/schema/introspection/Describable, com/apurebase/kgraphql/schema/introspection/Named {
945948
public abstract fun getArgs ()Ljava/util/List;
946949
public abstract fun getLocations ()Ljava/util/List;
947950
public abstract fun isRepeatable ()Z
948951
}
949952

950-
public abstract interface class com/apurebase/kgraphql/schema/introspection/__EnumValue : com/apurebase/kgraphql/schema/introspection/__Described, com/apurebase/kgraphql/schema/model/Depreciable {
953+
public abstract interface class com/apurebase/kgraphql/schema/introspection/__EnumValue : com/apurebase/kgraphql/schema/introspection/Describable, com/apurebase/kgraphql/schema/introspection/Named, com/apurebase/kgraphql/schema/model/Depreciable {
951954
}
952955

953-
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Field : com/apurebase/kgraphql/schema/introspection/__Described, com/apurebase/kgraphql/schema/model/Depreciable {
956+
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Field : com/apurebase/kgraphql/schema/introspection/Describable, com/apurebase/kgraphql/schema/introspection/Named, com/apurebase/kgraphql/schema/model/Depreciable {
954957
public abstract fun getArgs ()Ljava/util/List;
955958
public abstract fun getType ()Lcom/apurebase/kgraphql/schema/introspection/__Type;
956959
}
957960

958-
public abstract interface class com/apurebase/kgraphql/schema/introspection/__InputValue : com/apurebase/kgraphql/schema/introspection/__Described, com/apurebase/kgraphql/schema/model/Depreciable {
961+
public abstract interface class com/apurebase/kgraphql/schema/introspection/__InputValue : com/apurebase/kgraphql/schema/introspection/Describable, com/apurebase/kgraphql/schema/introspection/Named, com/apurebase/kgraphql/schema/model/Depreciable {
959962
public abstract fun getDefaultValue ()Ljava/lang/String;
960963
public abstract fun getType ()Lcom/apurebase/kgraphql/schema/introspection/__Type;
961964
}
@@ -968,8 +971,7 @@ public abstract interface class com/apurebase/kgraphql/schema/introspection/__Sc
968971
public abstract fun getTypes ()Ljava/util/List;
969972
}
970973

971-
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Type {
972-
public abstract fun getDescription ()Ljava/lang/String;
974+
public abstract interface class com/apurebase/kgraphql/schema/introspection/__Type : com/apurebase/kgraphql/schema/introspection/Describable {
973975
public abstract fun getEnumValues ()Ljava/util/List;
974976
public abstract fun getFields ()Ljava/util/List;
975977
public abstract fun getInputFields ()Ljava/util/List;

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/SchemaPrinter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package com.apurebase.kgraphql.schema
22

33
import com.apurebase.kgraphql.request.isIntrospectionType
44
import com.apurebase.kgraphql.schema.directive.Directive
5+
import com.apurebase.kgraphql.schema.introspection.Describable
6+
import com.apurebase.kgraphql.schema.introspection.Named
57
import com.apurebase.kgraphql.schema.introspection.TypeKind
6-
import com.apurebase.kgraphql.schema.introspection.__Described
78
import com.apurebase.kgraphql.schema.introspection.__Directive
89
import com.apurebase.kgraphql.schema.introspection.__InputValue
910
import com.apurebase.kgraphql.schema.introspection.__Schema
@@ -254,8 +255,7 @@ class SchemaPrinter(private val config: SchemaPrinterConfig = SchemaPrinterConfi
254255
?.joinToString(separator = " & ", prefix = " implements ") ?: ""
255256

256257
private fun Any.description(): String? = when (this) {
257-
is __Described -> description?.takeIf { it.isNotBlank() }
258-
is __Type -> description?.takeIf { it.isNotBlank() }
258+
is Describable -> description?.takeIf { it.isNotBlank() }
259259
else -> null
260260
}
261261

@@ -309,7 +309,7 @@ class SchemaPrinter(private val config: SchemaPrinterConfig = SchemaPrinterConfi
309309
private fun List<__Type>?.sortedByName() =
310310
orEmpty().sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name.toString() })
311311

312-
@JvmName("sortedDescribedByName")
313-
private fun <T : __Described> List<T>?.sortedByName() =
312+
@JvmName("sortedByName")
313+
private fun <T : Named> List<T>?.sortedByName() =
314314
orEmpty().sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
315315
}

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/__Described.kt renamed to kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/Describable.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.apurebase.kgraphql.schema.introspection
22

3-
interface __Described {
4-
val name: String
5-
3+
interface Describable {
64
val description: String?
75
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.apurebase.kgraphql.schema.introspection
2+
3+
interface Named {
4+
val name: String
5+
}

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/__Directive.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.apurebase.kgraphql.schema.introspection
22

33
import com.apurebase.kgraphql.schema.directive.DirectiveLocation
44

5-
interface __Directive : __Described {
5+
interface __Directive : Describable, Named {
66

77
val locations: List<DirectiveLocation>
88

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/__EnumValue.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package com.apurebase.kgraphql.schema.introspection
22

33
import com.apurebase.kgraphql.schema.model.Depreciable
44

5-
interface __EnumValue : Depreciable, __Described
5+
interface __EnumValue : Depreciable, Describable, Named

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/__Field.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.apurebase.kgraphql.schema.introspection
22

33
import com.apurebase.kgraphql.schema.model.Depreciable
44

5-
interface __Field : Depreciable, __Described {
5+
interface __Field : Depreciable, Describable, Named {
66

77
val type: __Type
88

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/__InputValue.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.apurebase.kgraphql.schema.introspection
22

33
import com.apurebase.kgraphql.schema.model.Depreciable
44

5-
interface __InputValue : Depreciable, __Described {
5+
interface __InputValue : Depreciable, Describable, Named {
66

77
val type: __Type
88

kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/introspection/__Type.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ package com.apurebase.kgraphql.schema.introspection
44
* GraphQL introspection system defines __Type to represent all of TypeKinds
55
* If some field does not apply to given type, it returns null
66
*/
7-
interface __Type {
7+
interface __Type : Describable {
88
val kind: TypeKind
99
val name: String?
10-
val description: String?
1110

1211
// OBJECT and INTERFACE only
1312
val fields: List<__Field>?

0 commit comments

Comments
 (0)