Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ class StitchedSchemaCompilation(

introspectTypes()

val typesByName =
(queryTypeProxies.values + enums.values + scalars.values + inputTypeProxies.values + unions.values).associateByTo(
mutableMapOf()
) { it.name }
val typesByName = mutableMapOf<String?, Type>().apply {
queryTypeProxies.values.forEach { put(it.name, it) }
enums.values.forEach { put(it.name, it) }
scalars.values.forEach { put(it.name, it) }
inputTypeProxies.values.forEach { put(it.name, it) }
unions.values.forEach { put(it.name, it) }
}
(remoteSchemaCompilation.remoteQueryTypeProxies + remoteSchemaCompilation.remoteInputTypeProxies).forEach {
if (typesByName[it.key] == null) {
typesByName[it.key] = it.value
Expand Down
6 changes: 0 additions & 6 deletions kgraphql-ktor/api/kgraphql-ktor.api
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,3 @@ public final class de/stuebingerb/kgraphql/GraphqlRequest$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class de/stuebingerb/kgraphql/KtorGraphQLConfiguration : de/stuebingerb/kgraphql/configuration/PluginConfiguration {
public fun <init> (ZLjava/lang/String;)V
public final fun getEndpoint ()Ljava/lang/String;
public final fun getPlayground ()Z
}

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class GraphQL(val schema: Schema) {
class FeatureInstance(featureKey: String = "KGraphQL") : Plugin<Application, Configuration, GraphQL> {
companion object {
private val playgroundHtml: ByteArray? by lazy {
KtorGraphQLConfiguration::class.java.classLoader.getResource("playground.html")?.readBytes()
GraphQL::class.java.classLoader.getResource("playground.html")?.readBytes()
}
}

Expand Down

This file was deleted.

13 changes: 2 additions & 11 deletions kgraphql-ktor/src/test/kotlin/de/stuebingerb/kgraphql/Kraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package de.stuebingerb.kgraphql

import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObjectBuilder
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.buildJsonObject

// MARK: Using this is a temporary solution as JCenter is closed down.
Expand Down Expand Up @@ -37,22 +36,14 @@ class Kraph(
Variable(name, typeName, buildJsonObject(block))
)

fun variable(name: String, typeName: String, value: String) = variables.add(
Variable(name, typeName, JsonPrimitive(value))
)

fun variable(name: String, typeName: String, value: Int) = variables.add(
Variable(name, typeName, JsonPrimitive(value))
)

private fun print(): String = buildString {
append("$type ")
if (variables.isNotEmpty() && root) {
append("MyQuery(${variables.joinToString(",") { "\$${it.name}: ${it.typeName}" }})")
}
if (fields.isNotEmpty()) {
appendLine("{")
fields.map { appendLine(it.print()) }
fields.forEach { appendLine(it.print()) }
appendLine("}")
} else {
appendLine()
Expand All @@ -66,7 +57,7 @@ class Kraph(
if (variables.isNotEmpty()) {
append(",")
append("\"variables\": {")
variables.map {
variables.forEach {
append("\"${it.name}\": ${it.value}")
}
append("}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class KtorMultipleEndpointsTest : KtorTest() {
}
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
val playgroundHtml =
KtorGraphQLConfiguration::class.java.classLoader.getResource("playground.html")
GraphQL::class.java.classLoader.getResource("playground.html")
.readText()

val response = client.get("/graphql")
Expand Down
44 changes: 0 additions & 44 deletions kgraphql/api/kgraphql.api
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,6 @@ public final class de/stuebingerb/kgraphql/schema/introspection/__Type$DefaultIm
public static fun unwrapped (Lde/stuebingerb/kgraphql/schema/introspection/__Type;)Lde/stuebingerb/kgraphql/schema/introspection/__Type;
}

public final class de/stuebingerb/kgraphql/schema/model/Add : de/stuebingerb/kgraphql/schema/model/DataActor {
public fun <init> (Ljava/lang/Object;Lkotlinx/coroutines/CompletableDeferred;)V
public final fun getKey ()Ljava/lang/Object;
public final fun getResult ()Lkotlinx/coroutines/CompletableDeferred;
}

public abstract class de/stuebingerb/kgraphql/schema/model/BaseOperationDef : de/stuebingerb/kgraphql/schema/model/Definition, de/stuebingerb/kgraphql/schema/model/FunctionWrapper, de/stuebingerb/kgraphql/schema/model/OperationDef {
public fun <init> (Ljava/lang/String;Lde/stuebingerb/kgraphql/schema/model/FunctionWrapper;Ljava/util/List;Lkotlin/jvm/functions/Function2;Lkotlin/reflect/KType;)V
public fun arity ()I
Expand All @@ -988,43 +982,11 @@ public abstract class de/stuebingerb/kgraphql/schema/model/BaseOperationDef : de
public fun valueParameters ()Ljava/util/List;
}

public abstract class de/stuebingerb/kgraphql/schema/model/DataActor {
}

public final class de/stuebingerb/kgraphql/schema/model/DataLoader {
public fun <init> (Lkotlin/jvm/functions/Function2;)V
public final fun begin (ILkotlinx/coroutines/CoroutineScope;)Lde/stuebingerb/kgraphql/schema/model/DataLoader$DataScope;
}

public final class de/stuebingerb/kgraphql/schema/model/DataLoader$DataScope : kotlinx/coroutines/CoroutineScope {
public fun <init> (Lde/stuebingerb/kgraphql/schema/model/DataLoader;ILkotlinx/coroutines/CoroutineScope;)V
public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
public final fun load (Ljava/lang/Object;Lkotlinx/coroutines/CompletableDeferred;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class de/stuebingerb/kgraphql/schema/model/DataLoaderKt {
public static final fun dataActor (Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/channels/SendChannel;
public static final fun log (Ljava/lang/String;)V
}

public abstract class de/stuebingerb/kgraphql/schema/model/Definition {
public fun <init> (Ljava/lang/String;)V
public final fun getName ()Ljava/lang/String;
}

public final class de/stuebingerb/kgraphql/schema/model/Deprecation {
public fun <init> (Ljava/lang/Object;Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/Object;
public final fun component2 ()Ljava/lang/String;
public final fun copy (Ljava/lang/Object;Ljava/lang/String;)Lde/stuebingerb/kgraphql/schema/model/Deprecation;
public static synthetic fun copy$default (Lde/stuebingerb/kgraphql/schema/model/Deprecation;Ljava/lang/Object;Ljava/lang/String;ILjava/lang/Object;)Lde/stuebingerb/kgraphql/schema/model/Deprecation;
public fun equals (Ljava/lang/Object;)Z
public final fun getReason ()Ljava/lang/String;
public final fun getTarget ()Ljava/lang/Object;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public abstract interface class de/stuebingerb/kgraphql/schema/model/Depreciable {
public abstract fun getDeprecationReason ()Ljava/lang/String;
public abstract fun isDeprecated ()Z
Expand Down Expand Up @@ -1226,11 +1188,6 @@ public final class de/stuebingerb/kgraphql/schema/model/FunctionWrapper$DefaultI
public static fun valueParameters (Lde/stuebingerb/kgraphql/schema/model/FunctionWrapper;)Ljava/util/List;
}

public final class de/stuebingerb/kgraphql/schema/model/Increment : de/stuebingerb/kgraphql/schema/model/DataActor {
public fun <init> (I)V
public final fun getCount ()I
}

public final class de/stuebingerb/kgraphql/schema/model/InputValueDef : de/stuebingerb/kgraphql/schema/model/Depreciable, de/stuebingerb/kgraphql/schema/model/DescribedDef {
public fun <init> (Lkotlin/reflect/KClass;Ljava/lang/String;Ljava/lang/Object;ZLjava/lang/String;Ljava/lang/String;Lkotlin/reflect/KType;Ljava/lang/String;)V
public synthetic fun <init> (Lkotlin/reflect/KClass;Ljava/lang/String;Ljava/lang/Object;ZLjava/lang/String;Ljava/lang/String;Lkotlin/reflect/KType;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down Expand Up @@ -2166,7 +2123,6 @@ public final class de/stuebingerb/kgraphql/schema/structure/SchemaModel : de/stu
public fun getMutationType ()Lde/stuebingerb/kgraphql/schema/structure/Type;
public synthetic fun getQueryType ()Lde/stuebingerb/kgraphql/schema/introspection/__Type;
public fun getQueryType ()Lde/stuebingerb/kgraphql/schema/structure/Type;
public final fun getQueryTypesByName ()Ljava/util/Map;
public final fun getRemoteTypesBySchema ()Ljava/util/Map;
public synthetic fun getSubscriptionType ()Lde/stuebingerb/kgraphql/schema/introspection/__Type;
public fun getSubscriptionType ()Lde/stuebingerb/kgraphql/schema/structure/Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ sealed class Execution {
val key = selectionNode.name.value
val aliasOrKey = selectionNode.aliasOrName.value

override val fullPath = parent?.fullPath.orEmpty() + aliasOrKey + listOfNotNull(arrayIndex)
override val fullPath = buildList {
parent?.let { addAll(it.fullPath) }
add(aliasOrKey)
arrayIndex?.let { add(it) }
}

internal fun withIndex(index: Int): Node = Node(
selectionNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal class ParallelRequestExecutor(val schema: DefaultSchema) : RequestExecu
execution.children.inspect()
if (execution.field is Field.DataLoader<*, *, *>) {
loaders[execution.field] =
execution.field.loader.constructNew(coroutineContext.job) as DataLoader<Any?, *>
execution.field.loader.constructNew(this@coroutineScope.coroutineContext.job) as DataLoader<Any?, *>
}
}
}
Expand Down Expand Up @@ -476,11 +476,10 @@ internal class ParallelRequestExecutor(val schema: DefaultSchema) : RequestExecu
return when {
hasReceiver -> CompletableDeferred(invoke(receiver, *transformedArgs.toTypedArray()))
isSubscription -> {
fun Execution.getSubscriptionArgs(): List<String> = when {
this is Execution.Node && children.isEmpty() -> listOf(aliasOrKey)
this is Execution.Node -> children.flatMap { it.getSubscriptionArgs() }
this is Execution.Fragment -> elements.flatMap { it.getSubscriptionArgs() }
else -> error("Unexpected type of node: $this")
fun Execution.getSubscriptionArgs(): List<String> = when (this) {
is Execution.Node if children.isEmpty() -> listOf(aliasOrKey)
is Execution.Node -> children.flatMap { it.getSubscriptionArgs() }
is Execution.Fragment -> elements.flatMap { it.getSubscriptionArgs() }
}

CompletableDeferred(invoke(transformedArgs, executionNode.getSubscriptionArgs(), objectWriter))
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import de.stuebingerb.kgraphql.schema.introspection.__InputValue
import de.stuebingerb.kgraphql.schema.introspection.__Schema
import de.stuebingerb.kgraphql.schema.introspection.__Type
import de.stuebingerb.kgraphql.schema.structure.validateName
import kotlin.enums.enumEntries
import kotlin.reflect.KClass
import kotlin.reflect.full.isSubclassOf

Expand All @@ -36,12 +37,12 @@ open class MutableSchemaDefinition {
TypeDef.Enumeration(
"__" + TypeKind::class.defaultKQLTypeName(),
TypeKind::class,
enumValues<TypeKind>().map { EnumValueDef(it) }
enumEntries<TypeKind>().map { EnumValueDef(it) }
),
TypeDef.Enumeration(
"__" + DirectiveLocation::class.defaultKQLTypeName(),
DirectiveLocation::class,
enumValues<DirectiveLocation>().map { EnumValueDef(it) }
enumEntries<DirectiveLocation>().map { EnumValueDef(it) }
)
)
protected val unions: ArrayList<TypeDef.Union> = arrayListOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ data class Location(
var line = 1
var column = position + 1

lineRegexp.findAll(source.body).toList().map {
lineRegexp.findAll(source.body).forEach {
if (it.range.first < position) {
line += 1
column = position + 1 - (it.range.first + it.value.length)
Expand Down
Loading
Loading