io.github.graphglue.data.execution.NodeQueryOptions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphglue-core Show documentation
Show all versions of graphglue-core Show documentation
A library to develop annotation-based code-first GraphQL servers using GraphQL Kotlin, Spring Boot and Neo4j - excluding Spring GraphQL server dependencies
The newest version!
package io.github.graphglue.data.execution
import io.github.graphglue.connection.order.IdOrder
import io.github.graphglue.connection.order.Order
/**
* Defines how a [NodeQuery] fetches data
*
* @param filters filters which are applied to filter out matched nodes
* @param orderBy the order in which nodes are ordered
* @param after if present, only nodes after this parsed cursor are fetched
* @param before if present, only properties before this parsed cursor are fetched
* @param first if present, only the first n nodes are fetched
* @param last if present, only the last n nodes are fetched
* @param fetchTotalCount totalCount is only fetched if `true`
* @param ignoreNodes if `true`, nodes are not fetched, only totalCount is fetched
* @param overrideIsAllQuery if `true`, this query is considered to fetch all nodes (use with caution)
*/
data class NodeQueryOptions(
val filters: List = emptyList(),
val orderBy: Order<*>? = IdOrder,
val after: Map? = null,
val before: Map? = null,
val first: Int? = null,
val last: Int? = null,
val skip: Int? = null,
val fetchTotalCount: Boolean = true,
val ignoreNodes: Boolean = false,
val overrideIsAllQuery: Boolean = false,
) {
init {
if ((first != null) && (last != null)) {
throw IllegalArgumentException("first and last can't both be present")
}
if (first != null && first < 0) {
throw IllegalArgumentException("first must be >= 0")
}
if (last != null && last < 0) {
throw IllegalArgumentException("last must be >= 0")
}
if (orderBy == null && (after != null || before != null)) {
throw IllegalArgumentException("orderBy must be present if after or before is present")
}
}
/**
* Can be used to check if a node fetches all nodes
*/
val isAllQuery: Boolean get() {
if (overrideIsAllQuery) {
return true
}
return (filters.isEmpty()) && (after == null) && (before == null) && (first == null) && (last == null) && !ignoreNodes
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy