Skip to content
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

Allow custom SqlDriver #4806

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -49,13 +49,13 @@ kotlin {

findByName("jvmMain")?.apply {
dependencies {
implementation(golatac.lib("sqldelight.jvm"))
api(golatac.lib("sqldelight.jvm"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try adding api("app.cash.sqldelight:runtime") to the commonMain source set instead of each individual platform? SqlDriver is in the runtime artifact (which is added automatically by the plugin) so there should be no need to leak other things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinbonnin Done! Used the version catalog + golatac for the reference, does that work?
re: incubating, I think it makes sense? Happy to put it wherever you think best.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, looks good 👍 . FWIW, the golatac stuff is a workaround for gradle/gradle#22095. We've seen some tasks being rerun due to version catalog accessors. Maybe it's better in newer versions of Gradle, I'll double check.

Re: incubating, incubating is easier for me because the API is still experimental so we can change it more easily. Let's start with this and if people ask for it in the main artifact, I'll backport.

}
}

findByName("appleMain")?.apply {
dependencies {
implementation(golatac.lib("sqldelight.native"))
api(golatac.lib("sqldelight.native"))
}
}

Expand All @@ -68,7 +68,7 @@ kotlin {
findByName("androidMain")?.apply {
dependencies {
api(golatac.lib("androidx.sqlite"))
implementation(golatac.lib("sqldelight.android"))
api(golatac.lib("sqldelight.android"))
implementation(golatac.lib("androidx.sqlite.framework"))
implementation(golatac.lib("androidx.startup.runtime"))
}
Expand All @@ -88,7 +88,7 @@ kotlin {

configure<com.android.build.gradle.LibraryExtension> {
compileSdk = golatac.version("android.sdkversion.compile").toInt()
namespace ="com.apollographql.apollo3.cache.normalized.sql"
namespace = "com.apollographql.apollo3.cache.normalized.sql"

defaultConfig {
minSdk = golatac.version("android.sdkversion.min").toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.apollographql.apollo3.cache.normalized.sql.internal.getSchema
import com.squareup.sqldelight.android.AndroidSqliteDriver
import com.squareup.sqldelight.db.SqlDriver

actual class SqlNormalizedCacheFactory internal constructor(
actual class SqlNormalizedCacheFactory actual constructor(
private val driver: SqlDriver,
private val withDates: Boolean,
) : NormalizedCacheFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.apollographql.apollo3.cache.normalized.sql.internal.getSchema
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver

actual class SqlNormalizedCacheFactory internal constructor(
actual class SqlNormalizedCacheFactory actual constructor(
private val driver: SqlDriver,
private val withDates: Boolean,
) : NormalizedCacheFactory() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.apollographql.apollo3.cache.normalized.sql

import com.apollographql.apollo3.cache.normalized.api.NormalizedCacheFactory
import com.squareup.sqldelight.db.SqlDriver

/**
* Creates a new [NormalizedCacheFactory] that uses a persistent cache based on Sqlite
Expand All @@ -16,5 +17,7 @@ import com.apollographql.apollo3.cache.normalized.api.NormalizedCacheFactory
* Once a database is created, this parameter cannot change
* Default: false
*/
expect class SqlNormalizedCacheFactory(name: String? = "apollo.db", withDates: Boolean = false) : NormalizedCacheFactory
expect class SqlNormalizedCacheFactory(name: String? = "apollo.db", withDates: Boolean = false) : NormalizedCacheFactory {
constructor(driver: SqlDriver, withDates: Boolean = false)
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver
import java.util.Properties

actual class SqlNormalizedCacheFactory internal constructor(
actual class SqlNormalizedCacheFactory actual constructor(
private val driver: SqlDriver,
private val withDates: Boolean,
) : NormalizedCacheFactory() {
Expand Down