mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-11 14:54:33 -05:00
Start working on graphql paging
This commit is contained in:
@@ -13,6 +13,8 @@ import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.andWhere
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.types.CategoryNodeList
|
||||
import suwayomi.tachidesk.graphql.types.CategoryNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.CategoryType
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||
import java.util.concurrent.CompletableFuture
|
||||
@@ -48,7 +50,7 @@ class CategoryQuery {
|
||||
val query: String? = null
|
||||
)
|
||||
|
||||
fun categories(input: CategoriesQueryInput? = null): List<CategoryType> {
|
||||
fun categories(input: CategoriesQueryInput? = null): CategoryNodeList {
|
||||
val results = transaction {
|
||||
val res = CategoryTable.selectAll()
|
||||
|
||||
@@ -72,6 +74,6 @@ class CategoryQuery {
|
||||
res.toList()
|
||||
}
|
||||
|
||||
return results.map { CategoryType(it) }
|
||||
return results.map { CategoryType(it) }.toNodeList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.andWhere
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.types.ChapterNodeList
|
||||
import suwayomi.tachidesk.graphql.types.ChapterNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.ChapterType
|
||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||
import java.util.concurrent.CompletableFuture
|
||||
@@ -56,7 +58,7 @@ class ChapterQuery {
|
||||
val count: Int? = null
|
||||
)
|
||||
|
||||
fun chapters(input: ChapterQueryInput? = null): List<ChapterType> {
|
||||
fun chapters(input: ChapterQueryInput? = null): ChapterNodeList {
|
||||
val results = transaction {
|
||||
var res = ChapterTable.selectAll()
|
||||
|
||||
@@ -97,6 +99,6 @@ class ChapterQuery {
|
||||
res.toList()
|
||||
}
|
||||
|
||||
return results.map { ChapterType(it) }
|
||||
return results.map { ChapterType(it) }.toNodeList() // todo paged
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.expediagroup.graphql.server.extensions.getValueFromDataLoader
|
||||
import graphql.schema.DataFetchingEnvironment
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.types.ExtensionNodeList
|
||||
import suwayomi.tachidesk.graphql.types.ExtensionNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.ExtensionType
|
||||
import suwayomi.tachidesk.manga.model.table.ExtensionTable
|
||||
import java.util.concurrent.CompletableFuture
|
||||
@@ -37,11 +39,11 @@ class ExtensionQuery {
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<String, ExtensionType>("ExtensionDataLoader", pkgName)
|
||||
}
|
||||
|
||||
fun extensions(): List<ExtensionType> {
|
||||
fun extensions(): ExtensionNodeList {
|
||||
val results = transaction {
|
||||
ExtensionTable.selectAll().toList()
|
||||
}
|
||||
|
||||
return results.map { ExtensionType(it) }
|
||||
return results.map { ExtensionType(it) }.toNodeList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.queries.util.GreaterOrLessThanLong
|
||||
import suwayomi.tachidesk.graphql.queries.util.andWhereGreaterOrLessThen
|
||||
import suwayomi.tachidesk.graphql.types.MangaNodeList
|
||||
import suwayomi.tachidesk.graphql.types.MangaNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.MangaType
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||
@@ -60,7 +62,7 @@ class MangaQuery {
|
||||
val count: Int? = null
|
||||
)
|
||||
|
||||
fun mangas(input: MangaQueryInput? = null): List<MangaType> {
|
||||
fun mangas(input: MangaQueryInput? = null): MangaNodeList {
|
||||
val results = transaction {
|
||||
var res = MangaTable.selectAll()
|
||||
|
||||
@@ -102,6 +104,6 @@ class MangaQuery {
|
||||
res.toList()
|
||||
}
|
||||
|
||||
return results.map { MangaType(it) }
|
||||
return results.map { MangaType(it) }.toNodeList() // todo paged
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.global.model.table.GlobalMetaTable
|
||||
import suwayomi.tachidesk.graphql.types.GlobalMetaItem
|
||||
import suwayomi.tachidesk.graphql.types.MetaItem
|
||||
import suwayomi.tachidesk.graphql.types.MetaNodeList
|
||||
import suwayomi.tachidesk.graphql.types.MetaNodeList.Companion.toNodeList
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
/**
|
||||
@@ -30,11 +32,11 @@ class MetaQuery {
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<String, MetaItem?>("GlobalMetaDataLoader", key)
|
||||
}
|
||||
|
||||
fun metas(): List<GlobalMetaItem> {
|
||||
fun metas(): MetaNodeList {
|
||||
val results = transaction {
|
||||
GlobalMetaTable.selectAll().toList()
|
||||
}
|
||||
|
||||
return results.map { GlobalMetaItem(it) }
|
||||
return results.map { GlobalMetaItem(it) }.toNodeList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.expediagroup.graphql.server.extensions.getValueFromDataLoader
|
||||
import graphql.schema.DataFetchingEnvironment
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.types.SourceNodeList
|
||||
import suwayomi.tachidesk.graphql.types.SourceNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.SourceType
|
||||
import suwayomi.tachidesk.manga.model.table.SourceTable
|
||||
import java.util.concurrent.CompletableFuture
|
||||
@@ -33,11 +35,11 @@ class SourceQuery {
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<Long, SourceType?>("SourceDataLoader", id)
|
||||
}
|
||||
|
||||
fun sources(): List<SourceType> {
|
||||
fun sources(): SourceNodeList {
|
||||
val results = transaction {
|
||||
SourceTable.selectAll().toList().mapNotNull { SourceType(it) }
|
||||
}
|
||||
|
||||
return results
|
||||
return results.toNodeList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.types.UpdatesNodeList
|
||||
import suwayomi.tachidesk.graphql.types.UpdatesNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.UpdatesType
|
||||
import suwayomi.tachidesk.manga.model.dataclass.PaginationFactor
|
||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||
@@ -31,7 +33,7 @@ class UpdatesQuery {
|
||||
val page: Int
|
||||
)
|
||||
|
||||
fun updates(input: UpdatesQueryInput): List<UpdatesType> {
|
||||
fun updates(input: UpdatesQueryInput): UpdatesNodeList {
|
||||
val results = transaction {
|
||||
ChapterTable.innerJoin(MangaTable)
|
||||
.select { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) }
|
||||
@@ -42,6 +44,6 @@ class UpdatesQuery {
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
return results.toNodeList() // todo paged
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user