-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MetaQuery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) Contributors to the Suwayomi project | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
package suwayomi.tachidesk.graphql.queries | ||
|
||
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.global.model.table.GlobalMetaTable | ||
import suwayomi.tachidesk.graphql.types.GlobalMetaItem | ||
import suwayomi.tachidesk.graphql.types.MetaItem | ||
import java.util.concurrent.CompletableFuture | ||
|
||
class MetaQuery { | ||
fun meta(dataFetchingEnvironment: DataFetchingEnvironment, key: String): CompletableFuture<MetaItem?> { | ||
return dataFetchingEnvironment.getValueFromDataLoader<String, MetaItem?>("GlobalMetaDataLoader", key) | ||
} | ||
|
||
fun metas(): List<GlobalMetaItem> { | ||
val results = transaction { | ||
GlobalMetaTable.selectAll().toList() | ||
} | ||
|
||
return results.map { GlobalMetaItem(it) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters