Skip to content

Prepare for K2 #5890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 16, 2024
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
2 changes: 1 addition & 1 deletion gradle/libraries.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ guava = "31.1-jre"
javaPoet = "1.13.0"
jetbrains-annotations = "24.0.1"
junit = "4.13.2"
kotlin-plugin-min = "1.8.0"
kotlin-plugin-min = "1.9.0"
kotlin-plugin = "2.0.0-RC3"
kotlin-plugin-max = "2.0.0-RC3"
kotlin-stdlib = "2.0.0-RC3"
Expand Down
6 changes: 0 additions & 6 deletions libraries/apollo-api/api/apollo-api.api
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,6 @@ public final class com/apollographql/apollo3/api/FileUpload {
}

public abstract interface class com/apollographql/apollo3/api/Fragment : com/apollographql/apollo3/api/Executable {
public abstract fun adapter ()Lcom/apollographql/apollo3/api/Adapter;
public abstract fun rootField ()Lcom/apollographql/apollo3/api/CompiledField;
public abstract fun serializeVariables (Lcom/apollographql/apollo3/api/json/JsonWriter;Lcom/apollographql/apollo3/api/CustomScalarAdapters;Z)V
}

public abstract interface class com/apollographql/apollo3/api/Fragment$Data : com/apollographql/apollo3/api/Executable$Data {
Expand Down Expand Up @@ -773,12 +770,9 @@ public final class com/apollographql/apollo3/api/ObjectType$Builder {
}

public abstract interface class com/apollographql/apollo3/api/Operation : com/apollographql/apollo3/api/Executable {
public abstract fun adapter ()Lcom/apollographql/apollo3/api/Adapter;
public abstract fun document ()Ljava/lang/String;
public abstract fun id ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun rootField ()Lcom/apollographql/apollo3/api/CompiledField;
public abstract fun serializeVariables (Lcom/apollographql/apollo3/api/json/JsonWriter;Lcom/apollographql/apollo3/api/CustomScalarAdapters;Z)V
}

public abstract interface class com/apollographql/apollo3/api/Operation$Data : com/apollographql/apollo3/api/Executable$Data {
Expand Down
6 changes: 0 additions & 6 deletions libraries/apollo-api/api/apollo-api.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,15 @@ abstract interface <#A: com.apollographql.apollo3.api/Executable.Data> com.apoll
}
}
abstract interface <#A: com.apollographql.apollo3.api/Fragment.Data> com.apollographql.apollo3.api/Fragment : com.apollographql.apollo3.api/Executable<#A> { // com.apollographql.apollo3.api/Fragment|null[0]
abstract fun adapter(): com.apollographql.apollo3.api/Adapter<#A> // com.apollographql.apollo3.api/Fragment.adapter|adapter(){}[0]
abstract fun rootField(): com.apollographql.apollo3.api/CompiledField // com.apollographql.apollo3.api/Fragment.rootField|rootField(){}[0]
abstract fun serializeVariables(com.apollographql.apollo3.api.json/JsonWriter, com.apollographql.apollo3.api/CustomScalarAdapters, kotlin/Boolean) // com.apollographql.apollo3.api/Fragment.serializeVariables|serializeVariables(com.apollographql.apollo3.api.json.JsonWriter;com.apollographql.apollo3.api.CustomScalarAdapters;kotlin.Boolean){}[0]
abstract interface Data : com.apollographql.apollo3.api/Executable.Data // com.apollographql.apollo3.api/Fragment.Data|null[0]
}
abstract interface <#A: com.apollographql.apollo3.api/Mutation.Data> com.apollographql.apollo3.api/Mutation : com.apollographql.apollo3.api/Operation<#A> { // com.apollographql.apollo3.api/Mutation|null[0]
abstract interface Data : com.apollographql.apollo3.api/Operation.Data // com.apollographql.apollo3.api/Mutation.Data|null[0]
}
abstract interface <#A: com.apollographql.apollo3.api/Operation.Data> com.apollographql.apollo3.api/Operation : com.apollographql.apollo3.api/Executable<#A> { // com.apollographql.apollo3.api/Operation|null[0]
abstract fun adapter(): com.apollographql.apollo3.api/Adapter<#A> // com.apollographql.apollo3.api/Operation.adapter|adapter(){}[0]
abstract fun document(): kotlin/String // com.apollographql.apollo3.api/Operation.document|document(){}[0]
abstract fun id(): kotlin/String // com.apollographql.apollo3.api/Operation.id|id(){}[0]
abstract fun name(): kotlin/String // com.apollographql.apollo3.api/Operation.name|name(){}[0]
abstract fun rootField(): com.apollographql.apollo3.api/CompiledField // com.apollographql.apollo3.api/Operation.rootField|rootField(){}[0]
abstract fun serializeVariables(com.apollographql.apollo3.api.json/JsonWriter, com.apollographql.apollo3.api/CustomScalarAdapters, kotlin/Boolean) // com.apollographql.apollo3.api/Operation.serializeVariables|serializeVariables(com.apollographql.apollo3.api.json.JsonWriter;com.apollographql.apollo3.api.CustomScalarAdapters;kotlin.Boolean){}[0]
abstract interface Data : com.apollographql.apollo3.api/Executable.Data // com.apollographql.apollo3.api/Operation.Data|null[0]
}
abstract interface <#A: com.apollographql.apollo3.api/Query.Data> com.apollographql.apollo3.api/Query : com.apollographql.apollo3.api/Operation<#A> { // com.apollographql.apollo3.api/Query|null[0]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
package com.apollographql.apollo3.api

import com.apollographql.apollo3.api.json.JsonWriter
import okio.IOException

/**
* Base interface for a fragment implementation.
* Fragments do not have variables per the GraphQL spec but they are inferred from arguments and used when reading the cache
* See https://github.com/graphql/graphql-spec/issues/204 for a proposal to add fragment arguments
*/
interface Fragment<D : Fragment.Data> : Executable<D> {
@Throws(IOException::class)
override fun serializeVariables(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, withDefaultValues: Boolean)

override fun adapter(): Adapter<D>

override fun rootField(): CompiledField

/**
* Marker interface for generated models of this fragment
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.apollographql.apollo3.api

import com.apollographql.apollo3.api.json.JsonWriter
import okio.IOException
import kotlin.js.JsName

/**
Expand Down Expand Up @@ -29,13 +27,6 @@ interface Operation<D : Operation.Data> : Executable<D> {
@JsName("operationId")
fun id(): String

override fun adapter(): Adapter<D>

@Throws(IOException::class)
override fun serializeVariables(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, withDefaultValues: Boolean)

override fun rootField(): CompiledField

/**
* Marker interface for generated models built from data returned by the server in response to this operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object KotlinCompiler {
val result = KotlinCompilation().apply {
sources = kotlinFiles

kotlincArguments = kotlincArguments + "-opt-in=kotlin.RequiresOptIn"
kotlincArguments = kotlincArguments + "-opt-in=kotlin.RequiresOptIn" + "-Xskip-prerelease-check"
inheritClassPath = true
verbose = false
messageOutputStream = okio.blackholeSink().buffer().outputStream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.android.build.gradle.BaseExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand Down Expand Up @@ -41,5 +40,6 @@ tasks.withType<KotlinCompile>().configureEach {
// Required for Kotlin < 1.6.10
// See https://kotlinlang.org/docs/whatsnew1620.html#compatibility-changes-in-the-xjvm-default-modes
freeCompilerArgs += "-Xjvm-default=all"
freeCompilerArgs += "-Xskip-prerelease-check"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ final fun com.apollographql.apollo3.testing/cwd(): kotlin/String // com.apollogr
// Targets: [js]
final val com.apollographql.apollo3.testing/HostFileSystem // com.apollographql.apollo3.testing/HostFileSystem|{}HostFileSystem[0]
final fun <get-HostFileSystem>(): okio/FileSystem // com.apollographql.apollo3.testing/HostFileSystem.<get-HostFileSystem>|<get-HostFileSystem>(){}[0]
// Targets: [wasmJs]
final val com.apollographql.apollo3.testing.internal/empty // com.apollographql.apollo3.testing.internal/empty|{}empty[0]
final fun <get-empty>(): kotlin.js/JsAny // com.apollographql.apollo3.testing.internal/empty.<get-empty>|<get-empty>(){}[0]
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.promise
import kotlin.coroutines.CoroutineContext
import kotlin.js.Promise

// https://youtrack.jetbrains.com/issue/KT-21846/
@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE", "INCOMPATIBLE_MATCHING")
@ApolloInternal
actual typealias ApolloTestResult = Promise<Any>
actual typealias ApolloTestResult = JsPromiseInterfaceForTesting

// https://youtrack.jetbrains.com/issue/KT-60561
@ApolloInternal
@JsName("Promise")
external class JsPromiseInterfaceForTesting {
fun then(onFulfilled: ((Unit) -> Unit), onRejected: ((Throwable) -> Unit)): JsPromiseInterfaceForTesting
fun then(onFulfilled: ((Unit) -> Unit)): JsPromiseInterfaceForTesting
}

@ApolloInternal
@OptIn(DelicateCoroutinesApi::class)
Expand Down Expand Up @@ -40,5 +45,5 @@ actual fun runTest(
after()
}
}
}
}.unsafeCast<ApolloTestResult>()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,48 @@ package com.apollographql.apollo3.testing.internal

import com.apollographql.apollo3.annotations.ApolloInternal
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.promise
import kotlin.coroutines.CoroutineContext
import kotlin.js.Promise

@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE", "INCOMPATIBLE_MATCHING")
@ApolloInternal
actual typealias ApolloTestResult = Promise<JsAny>
actual typealias ApolloTestResult = JsPromiseInterfaceForTesting

/**
* Utility method that executes the given [block] with optional [before] and [after] blocks.
*
* When [skipDelays] is `true`, the block is executed in [kotlinx.coroutines.test.runTest], otherwise in `runBlocking`.
*/
// https://youtrack.jetbrains.com/issue/KT-60561
@ApolloInternal
@JsName("Promise")
external class JsPromiseInterfaceForTesting: JsAny {
fun then(onFulfilled: ((JsAny) -> Unit), onRejected: ((JsAny) -> Unit)): JsPromiseInterfaceForTesting
fun then(onFulfilled: ((JsAny) -> Unit)): JsPromiseInterfaceForTesting
}

@ApolloInternal
@OptIn(DelicateCoroutinesApi::class)
actual fun runTest(
skipDelays: Boolean,
context: CoroutineContext,
before: suspend CoroutineScope.() -> Unit,
after: suspend CoroutineScope.() -> Unit,
block: suspend CoroutineScope.() -> Unit,
): ApolloTestResult {
return Promise.resolve(empty)
return if (skipDelays) {
kotlinx.coroutines.test.runTest(context) {
before()
try {
block()
} finally {
after()
}
}
} else {
GlobalScope.promise(context = context) {
before()
try {
block()
} finally {
after()
}
}
}.unsafeCast()
}

val empty: JsAny = js("({})")
Loading